Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Genesis breadcrumbs for tag1+tag2 or tag1,tag2 combined term archives
<?php
// Display titles of all terms in combined term archive breadcrumbs (tag1+tag2 or tag1,tag2)
function scl_multiple_tax_breadcrumbs( $crumbs, $args ) {
if ( !is_tax() )
return $crumbs;
$taxonomy = get_query_var( 'taxonomy' );
$topics = get_query_var( $taxonomy );
if ( empty( $topics ) )
return $crumbs;
$hascomma = strpos( $topics, ',' );
$hasplus = strpos( $topics, '+' );
if ( $hascomma !== false OR $hasplus !== false ) {
if ( $hascomma ) {
$sep = ',';
$glue = ' or ';
}
else {
$sep = '+';
$glue = ' and ';
}
$crumb = end( $crumbs );
$linkedcrumbs = substr( $crumb, 0, strrpos( $crumb, $args['sep'] ) );
$newcrumbs = array();
$terms = explode( $sep, $topics );
foreach ( $terms as $term ) {
$termobj = get_term_by( 'slug', $term, 'work_zone_topics' );
$newcrumbs[] = $termobj->name;
}
$crumbs = array( $linkedcrumbs, implode( $glue, $newcrumbs ) );
}
return $crumbs;
}
add_filter( 'genesis_build_crumbs', 'scl_multiple_tax_breadcrumbs', 10, 2 );
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.