Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Created October 16, 2016 21:05
Show Gist options
  • Save stephanieleary/4f592e462ea51866082a099b11c6309d to your computer and use it in GitHub Desktop.
Save stephanieleary/4f592e462ea51866082a099b11c6309d to your computer and use it in GitHub Desktop.
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