Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Created March 5, 2015 08:58
Show Gist options
  • Select an option

  • Save designbuildtest/af405bd787ffd1309c3b to your computer and use it in GitHub Desktop.

Select an option

Save designbuildtest/af405bd787ffd1309c3b to your computer and use it in GitHub Desktop.
Breadcrumbs - Modified/Big Brother theme
/**
* Breadcrumbs @ https://wpcom-themes.svn.automattic.com/big-brother/functions.php
*/
function myplugin_breadcrumbs() { ?>
<div class="breadcrumbs">
<?php
$sep = '<span class="breadcrumbs-seperator">' . __( '&raquo;' ) . '</span>';
$before = '<span class="breadcrumbs-current">' . $sep ;
$after = '</span>';
echo '<a class="breadcrumbs-home" href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Home' ) . '</a>';
if ( is_attachment() ) {
global $post;
if ( $post->post_parent ) {
echo $sep . '<a class="breadcrumbs-ancestor" href="' . esc_url( get_permalink( $post->post_parent ) ) . '">' . get_the_title( $post->post_parent ) . '</a>' . $before . get_the_title() . $after;
}
else {
echo $before . get_the_title() . $after;
}
}
elseif ( is_page() ) {
global $post;
if ( $post->post_parent ) {
$parent_id = $post->post_parent;
$parent_links = array();
while ( $parent_id ) {
$page = get_post( $parent_id );
$parent_links[] = $sep . '<a class="breadcrumbs-ancestor" href="' . esc_url( get_permalink( $page->ID ) ) . '">' . get_the_title( $page->ID ) . '</a>';
$parent_id = $page->post_parent;
}
echo implode( array_reverse( $parent_links ) );
}
echo $before . get_the_title() . $after;
}
elseif ( is_search() ) {
echo $before . sprintf( __( 'Search results for &#39;%s&#39;' ), get_search_query() ) . $after;
}
elseif ( is_404() ) {
echo $before . __( 'Page not found' ) . $after;
}
?>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment