Skip to content

Instantly share code, notes, and snippets.

@markwearing
Created October 16, 2012 15:25
Show Gist options
  • Select an option

  • Save markwearing/3899950 to your computer and use it in GitHub Desktop.

Select an option

Save markwearing/3899950 to your computer and use it in GitHub Desktop.
A breadcrumb function for the Wordpress boilerplate theme.
if ( ! function_exists( 'oneltd_get_breadcrumbs' ) ):
/*
* AO: Breadcrumbs function to echo out crumbs in LI's (With #breadcrumbs containing UL).
*
*/
function oneltd_get_breadcrumbs()
{
global $post;
$ancestors = get_post_ancestors( $post );
$ancestors = array_reverse($ancestors);
$ancestors[] = $post->ID;
echo '<ul id="breadcrumbs">';
// If on the "homepage" (posts listing page) display blog as the top page - easily changed to news etc!
if( is_home() ):
echo '<li><a href="/blog">blog</a></li>';
else:
foreach($ancestors as $crumb)
{
echo '<li><a href="';
echo get_permalink($crumb);
echo '">';
echo get_the_title($crumb);
echo '</a></li>';
}
endif;
echo '</ul>';
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment