Skip to content

Instantly share code, notes, and snippets.

@billerickson
Created January 11, 2012 22:40
Show Gist options
  • Save billerickson/1597218 to your computer and use it in GitHub Desktop.
Save billerickson/1597218 to your computer and use it in GitHub Desktop.
<?php
// This is on the taxonomy archive page, like taxonomy-colors.php
// First get the info about the current term
$term = get_term_by( 'slug', get_query_var( 'colors' ), 'colors' );
// Then see if there's any children of this tax term
$children = get_terms( 'colors', array( 'child_of' => $term->term_id ) );
// If there are children, loop through each and do your own query
if( $children ) {
foreach( $children as $child ) {
$loop = new WP_Query( array( 'colors' => $child->slug ) );
...
}
// If there aren't children, do the standard loop that shows all the posts in the current tax term
} else {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment