Created
June 27, 2013 16:11
-
-
Save ChrisLTD/5877800 to your computer and use it in GitHub Desktop.
Loop through all custom taxonomy terms for a post type
This file contains hidden or 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
<?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