-
-
Save billerickson/5c382c95e356064db308 to your computer and use it in GitHub Desktop.
This file contains 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 Category to Event Breadcrumb | |
* @author Bill Erickson | |
* @link http://www.billerickson.net/code/add-taxonomy-to-genesis-breadcrumb | |
* | |
* @param string $crumb, current breadcrumb | |
* @param array $args, the breadcrumb arguments | |
* @return string $crumb, modified breadcrumb | |
*/ | |
function be_event_breadcrumb( $crumb, $args ) { | |
// Only modify the breadcrumb if in the 'events' post type | |
if( 'events' !== get_post_type() ) | |
return $crumb; | |
// Grab terms | |
$terms = get_the_terms( get_the_ID(), 'event-category' ); | |
if( empty( $terms ) || is_wp_error( $terms ) ) | |
return $crumb; | |
// Only use one term | |
$term = array_shift( $terms ); | |
// Build the breadcrumb | |
$crumb = '<a href="' . get_post_type_archive_link( 'events' ) . '">Events</a>' . $args['sep'] . '<a href="' . get_term_link( $term, 'event-category' ) . '">' . $term->name . '</a>' . $args['sep'] . get_the_title(); | |
return $crumb; | |
} | |
add_filter( 'genesis_single_crumb', 'be_event_breadcrumb', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment