Skip to content

Instantly share code, notes, and snippets.

@mrbobbybryant
Created April 19, 2015 20:18
Show Gist options
  • Save mrbobbybryant/238578ac4d4fb500bf63 to your computer and use it in GitHub Desktop.
Save mrbobbybryant/238578ac4d4fb500bf63 to your computer and use it in GitHub Desktop.
Querying all taxonomies for all post types
<?php
function agency_wp_test() {
$post_types = get_post_types();
foreach ( $post_types as $post_type ) {
$taxonomy_names = get_object_taxonomies( $post_type );
$terms = get_terms( $taxonomy_names, array( 'hide_empty' => false ));
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<h5>'.$post_type.'</h5>';
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li>' . $term->name . '</li>';
}
echo '</ul>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment