1955 Design | Websites that Look Good, Work Properly and Search Engines Love
WordPress Breadcrumb Script

Facebook icon
Follow 1955Design on Twitter
Blog icon
RSS icon
 

WordPress Breadcrumb Script

by David Zemens · December 18, 2008 · WordPress

While searching the WordPress forums for the answer to another problem, I stumbled upon this script that places a breadcrumb navigation trail into your WordPress theme template.

It’s easy to use and works like a charm. It would have taken me hours and hours to figure out how to do this myself, so I am glad it was available to me without having to reinvent the wheel. I hope you can put it to use, too.

<div id="breadcrumbs">;
  <span>You are here: </span>
	<a href="<?php echo get_bloginfo('url'); ?>" title="">Home</a>
	  <?php
		$parent_id  = $post->post_parent;
		$breadcrumbs = array();
		while ($parent_id) {
		  $page = get_page($parent_id);
		  $breadcrumbs[] = '<a href="'.get_permalink($page->ID).'" title="">'.get_the_title($page->ID).</a>';
		  $parent_id  = $page->post_parent;
		}
		$breadcrumbs = array_reverse($breadcrumbs);
		foreach ($breadcrumbs as $crumb) echo ' » '.$crumb;
	  ?>
	 <span> » <?php the_title(); ?></span>
</div>

[eof]

0 Comments & Trackbacks

 

Leave your comment

Your privacy is safe at 1955 Design. See our Privacy Policy for further details.