Created
October 16, 2016 21:43
-
-
Save stephanieleary/1a9730df2d377f83c52a79d792aa54d3 to your computer and use it in GitHub Desktop.
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 | |
add_action( 'genesis_loop', 'scl_people_types_loop', 10 ); | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
function scl_people_types_loop( $parent = 0 ) { | |
$terms = get_terms( array( | |
'taxonomy' => 'people_type', | |
'hide_empty' => true, | |
'parent' => $parent, | |
) ); | |
if ( empty( $terms ) ) | |
return; | |
global $query_args; | |
foreach ( $terms as $term ) { | |
if ( $term->parent ) { | |
printf( '<h2 %s>%s</h2>', genesis_attr( 'archive-title' ), strip_tags( $term->name ) ); | |
scl_people_types_loop( $term->term_id ); | |
continue; | |
} | |
$args = array( | |
'fields' => 'ids', | |
'posts_per_page' => -1, | |
'posts_per_archive_page' => -1, | |
'post_type' => 'people', | |
'tax_query' => array( | |
array( | |
'taxonomy' => $taxonomy, | |
'field' => 'slug', | |
'terms' => $term->slug, | |
), | |
), | |
); | |
$have_posts = wp_parse_args( $args, $query_args ); | |
if ( count( $have_posts ) ) { | |
echo '<div class="people_type_loop '.$term->slug. ' ' .$taxonomy.'">'; | |
remove_action( 'genesis_loop_else', 'genesis_do_noposts' ); | |
remove_action( 'genesis_after_endwhile', 'genesis_posts_nav' ); | |
printf( '<h2 %s>%s</h2>', genesis_attr( 'archive-title' ), strip_tags( $term->name ) ); | |
unset( $args['fields'] ); | |
genesis_custom_loop( wp_parse_args( $args, $query_args ) ); | |
echo '</div>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment