Skip to content

Instantly share code, notes, and snippets.

@billerickson

billerickson/functions.php Secret

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