Skip to content

Instantly share code, notes, and snippets.

@ChrisLTD
Created June 27, 2013 16:11
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisLTD/5877800 to your computer and use it in GitHub Desktop.
Save ChrisLTD/5877800 to your computer and use it in GitHub Desktop.
Loop through all custom taxonomy terms for a post type
<?php
$post_type = 'post';
// Get all the taxonomies for this post type
$taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) );
foreach( $taxonomies as $taxonomy ){
// Gets every "category" (term) in this taxonomy to get the respective posts
$terms = get_terms( $taxonomy );
foreach( $terms as $term ){
echo $term->name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment