Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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
You can’t perform that action at this time.