In the template:

<?php // Breadcrumb navigation
 if (is_page() && !is_front_page() || is_single() || is_category()) {
 echo '<ul>';
 echo '<li><a href="'.get_bloginfo('url').'">Home</a>&nbsp;';
 if (is_page()) {
 $ancestors = get_post_ancestors($post);

 if ($ancestors) {
 $ancestors = array_reverse($ancestors);

 foreach ($ancestors as $crumb) {
 echo '<li><a href="'.get_permalink($crumb).'">'.get_the_title($crumb).'</a>&nbsp;</li>';
 }
 }
 }

 if (is_single()) {
 $category = get_the_category();
 echo '<li><a href="'.get_category_link($category[0]->cat_ID).'">'.$category[0]->cat_name.'</a>&nbsp;</li>';
 }

 if (is_category()) {
 $category = get_the_category('depth=2');
 echo '<li>'.$category[0]->cat_name.'</li>';
 }

 // Current page
 if (is_page() || is_single()) {
 echo '<li>'.get_the_title().'</li>';
 }
 echo '</ul>';
 } elseif (is_front_page()) {
 // Front page
 echo '<ul>';
 echo '<li>'.get_bloginfo('description').'</li>';
 echo '</ul>';
 }
?>    


Style:


.breadcrumbs li { list-style-type: none;float: left; margin: 0 0.5em 0 0;}
.breadcrumbs li:before {content: "» ";}
.breadcrumbs .front_page:before {content: none;}

Leave a comment