Created
August 24, 2020 19:15
-
-
Save jesseschmidt/d8af08215d87f8d71815545b196607eb to your computer and use it in GitHub Desktop.
WordPress get all terms from categories and tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$term_query = new WP_Term_Query( | |
array( | |
'taxonomy' => array('category','post_tag'), | |
'order' => 'ASC', | |
'orderby' => 'name' | |
) | |
); | |
if ( ! empty( $term_query->terms ) ) { | |
foreach ( $term_query->terms as $term ) { | |
echo $term->name; | |
} | |
} else { | |
echo 'No terms found.'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment