Last active
November 10, 2016 01:42
-
-
Save titus-shoats/5e83018b53534200179f5e14ea904220 to your computer and use it in GitHub Desktop.
Get Wordpress Post Types Within Taxonomies
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
<?php | |
$args = array( | |
'public' => true, | |
'_builtin' => false | |
); | |
$post_types = get_post_types($args, 'names', 'and'); | |
foreach ($post_types as $post_type) { | |
/** | |
* If theres any post types within this taxonomy | |
*/ | |
if (get_object_taxonomies($post_type, 'names')): | |
foreach (get_object_taxonomies($post_type, 'names') as $taxonomy) { | |
$get_posts_tax[] = get_terms( | |
array( | |
'taxonomy' => $taxonomy, | |
'hide_empty' => false, | |
'hierarchical' => true | |
)); | |
// echo "<pre/>"; | |
// echo "<pre/>"; | |
} | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment