Site icon WP Smith

How to Create a Custom NonHierarchical Taxonomy Breadcrumb in Genesis

Recently I had the need to create a custom taxonomy breadcrumb because my custom taxonomy was non-hierarchical (like Tags). However, the launch page for this tag was lost in the Breadcrumbs, so I needed to add it back. Since my custom taxonomy was rather simple, filtering the already existent Breadcrumb class didn't make sense to me. However, I was stumped, so I reached out to Bill Erickson on Twitter (@BillErickson). He came up with this awesome, simple solution:

[php]remove_action('genesis_before_loop', 'genesis_do_breadcrumbs');
add_action('genesis_before_loop', 'tax_breadcrumbs');

function tax_breadcrumbs() {
if (is_tax()):
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
echo '<div class="breadcrumb"><a href="'.get_bloginfo('url').'">Home</a> | <a href="/page-name">Page Name</a> | '.$term->name.'</div>';
endif;

} [/php]