Skip to content

Instantly share code, notes, and snippets.

@ckpicker
Created October 22, 2014 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ckpicker/6875eb645a28df2a6db2 to your computer and use it in GitHub Desktop.
Save ckpicker/6875eb645a28df2a6db2 to your computer and use it in GitHub Desktop.
The Events Calendar // Add Breadcrumbs support to TEC
// Check if page is direct child
function is_child( $page_id ) {
global $post;
if( is_page() && ($post->post_parent != '') ) {
return true;
} else {
return false;
}
}
// Breadcrumb Logic
function tribe_breadcrumbs() {
global $post;
$separator = " » ";
echo '<div class="tribe-breadcrumbs">';
echo '<a href="' . get_option('home') . '">' . bloginfo( 'name' ) . '</a>';
if( tribe_is_month() && !is_tax() ) { // The Main Calendar Page
echo $separator;
echo 'The Events Calendar';
} elseif( tribe_is_month() && is_tax() ) { // Calendar Category Pages
global $wp_query;
$term_slug = $wp_query->query_vars['tribe_events_cat'];
$term = get_term_by('slug', $term_slug, 'tribe_events_cat');
get_term( $term_id, 'tribe_events_cat' );
$name = $term->name;
echo $separator;
echo '<a href="'.tribe_get_events_link().'">Events</a>';
echo $separator;
echo $name;
} elseif( tribe_is_event() && !tribe_is_day() && !is_single() ) { // The Main Events List
echo $separator;
echo 'Events List';
} elseif( tribe_is_event() && is_single() ) { // Single Events
echo $separator;
echo '<a href="'.tribe_get_events_link().'">Events</a>';
echo $separator;
the_title();
} elseif( tribe_is_day() ) { // Single Event Days
global $wp_query;
echo $separator;
echo '<a href="'.tribe_get_events_link().'">Events</a>';
echo $separator;
echo 'Events on: ' . date('F j, Y', strtotime( $wp_query->query_vars['eventDate']) );
} elseif( tribe_is_venue() ) { // Single Venues
echo $separator;
echo '<a href="'.tribe_get_events_link().'">Events</a>';
echo $separator;
the_title();
} elseif ( is_category() || is_single() ) {
echo $separator;
the_category(' &bull; ');
if ( is_single() ) {
echo ' '.$separator.' ';
the_title();
}
} elseif ( is_page() ) {
if( is_child(get_the_ID()) ) {
echo $separator;
echo '<a href="' . get_permalink( $post->post_parent ) . '">' . get_the_title( $post->post_parent ) . '</a>';
echo $separator;
echo the_title();
} else {
echo $separator;
echo the_title();
}
} elseif (is_search()) {
echo $separator.'Search Results for... ';
echo '"<em>';
echo the_search_query();
echo '</em>"';
}
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment