Skip to content

Instantly share code, notes, and snippets.

@jesseschmidt
Created August 24, 2020 19:15
Show Gist options
  • Save jesseschmidt/d8af08215d87f8d71815545b196607eb to your computer and use it in GitHub Desktop.
Save jesseschmidt/d8af08215d87f8d71815545b196607eb to your computer and use it in GitHub Desktop.
WordPress get all terms from categories and tags
$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