How to list all names and descriptions of a custom taxonomy
-
02-10-2020 - |
Question
I have a custom taxonomy (toolkit-sections) inside a custom post type (toolkit-tools) and I'm looking to just list the taxonomy names and descriptions from toolkit-sections on a homepage.
I don't want to list any posts from inside these taxonomies, I just want to show what the taxonomies are called and what their descriptions are.
Do you know how to do this? I really, really would appreciate any help!
Solution
You can use get_terms.
In your case, something like this ought to get you started:
$term_list = get_terms( 'taxonomy_name', 'hide_empty=0&orderby=name' );
foreach( $term_list as $term ) {
echo "<li>" . $term->name . $term->description . "</li>";
}
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange