Skip to content

Instantly share code, notes, and snippets.

@titus-shoats
Last active November 10, 2016 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save titus-shoats/5e83018b53534200179f5e14ea904220 to your computer and use it in GitHub Desktop.
Save titus-shoats/5e83018b53534200179f5e14ea904220 to your computer and use it in GitHub Desktop.
Get Wordpress Post Types Within Taxonomies
<?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