Breadcrumbs, as has been said before on WPHacks, are very useful, both for your SEO and reader’s navigation. In other words, there is no reason why you shouldn’t have them on your site.
There are a number of breadcrumb plugins you could use, but with a bit of Wordpress code, you can avoid this. If you use sub-categories, then this will only display the name of the sub category.
A typical breadcrumb is something like this:
Home >> [Category] >> [Post Title]
Wordpress can very easily do this - to get the name of the category the post is in, all you need is
<?php the_category(); ?>
Then, to display the post title, the code you need is
<?php the_title(); ?>
So our final code, with some arrows added in is:
<a href="/">Home</a> » <?php the_category(' '); ?> » <?php the_title(); ?>
So now that you’ve got your breadcrumb sorted, you can take this one step further and spice it up a bit. For the next part, we’re going to be using the code from a tutorial at Janko at Warp Speed, and with this code, we’re going to turn our breadcrumb into something that looks like the ones you see on Apple.com!
The Apple.com breadcrumb:

And what we’re making:
First, download the html version here, and open it in a your web editor (ie Notepad, Dreamweaver etc). Scroll down until you find <ul id=”breadcrumb”>. This is where we’re going to start editing. All you need to do is copy and paste the following code:
<ul id="breadcrumb">
<li><a href="/" title="Home"><img src="/images/home.png" alt="Home" class="home" /></a></li>
<li><?php the_category(', ') ?></li>
<li><?php the_title(); ?></li>
</ul>
This is basically the same code as we had above, just putting into a list. Make sure you upload the home.png file to /images/, and while you’re at it, upload the other images.
Next thing we need to do is the CSS. Go into your style.css and paste the following:
#breadcrumb {
font: 11px Arial, Helvetica, sans-serif;
height:30px;
line-height:30px;
color:#9b9b9b;
border:solid 1px #cacaca;
width:100%;
overflow:hidden;
margin:0px;
padding:0px;
}
#breadcrumb li {
list-style-type:none;
float:left;
padding-left:10px;
}
#breadcrumb a {
height:30px;
display:block;
background-image:url('/images/bc_separator.png');
background-repeat:no-repeat;
background-position:right;
padding-right: 15px;
text-decoration: none;
color:#000;
}
.home {
border:none;
margin: 8px 0px;
}
#breadcrumb a:hover {
color:#35acc5;
}
Once you’ve done that, then you’re done! If you copy the code from the source file (which you should), then make sure you change the url of the images.
I recently redesigned one of my sites, and integrated this, so you can see a working example here.
This was a guest post by Alex Denning, who is a Wordpress power user, web design freelancer and currently maintains two sites - Nometet.com and GreenGrassGames.com. You can follow him on Twitter here. If you have WordPress knowledge and are interested in writing a post for WordPress Hacks, please contact us.



Friday, January 2nd, 2009 at 5:29 am
That is freaking cool. It had never occurred to me that you could create a bread crumb like that… awesome.
Friday, January 2nd, 2009 at 6:24 am
Why is it called a breadcrumb?
Friday, January 2nd, 2009 at 1:29 pm
@fahirsch - breadcrumbs are used to “find your way home.” If the site has a complex tree structure it can be useful to go back to a middle point rather than all the way home.
Example: Home: Category 1: Category 1a: Detail
A user might want to see Category 1b. Instead of going all the way home they could click Category 1 instead, saving the a click and page load
Saturday, January 3rd, 2009 at 9:34 am
Great. This is just documentated to the max.
Very well done. Stumbled.
Pssht! I never knew what was meant by BreadCrumbs.
But, now, I know, what is it, and why is it called the name.
NOTE: I’m falling in love with your awesome theme.
Oh yeah!, I see the Blog Design Studio banner there.
No wonder
Saturday, January 3rd, 2009 at 5:51 pm
Nice tutorial. Breadcrumps are a key piece of navigation on blogs with a lot of articles or categories.
Sunday, January 4th, 2009 at 2:56 am
Very nice tutorial indeed and what make it so great is that no plugin is needed.
Sunday, January 4th, 2009 at 5:30 pm
Ha! That’s pretty awesome. I’ll try it out, check out the results at http://defaultprime.com. Thanks again!
Monday, January 5th, 2009 at 5:30 am
Thanks for all of the great feedback!
I’ve just dugg this, so if anyone is on Digg, the link is here: http://tr.im/2y49
Tuesday, January 6th, 2009 at 7:33 pm
I was looking for some code that would generate a breadcrumb if you had both categories AND sub-categories, and (to make life easier) assigned each post to only one sub-category.
Anyway, I finally hacked into the WP files, made a few changes, and now can generate a breadcrumb trail with just one line of PHP: http://www.malcolmcoles.co.uk/blog/breadcrumb-trails-in-wordpress/
Saturday, January 10th, 2009 at 10:50 pm
It always shows the path to the last post, including home page.
Fix this -
???????
Here is my full post - http://alexvolkov.ru/navigaciya-v-stile-applecom-dlya-wordpress.html
Monday, March 2nd, 2009 at 10:15 am
Nice way of implementing this in a Wordpress installation! I’ve read tutorials on how to recreate the Mac-style breadcrumb menu but they rarely go that extra one step to suggest how to implement it in Wordpress - and you’ve done it. Thank you so much for sharing!
There’s a simply Breadcrumb plugin out there but it doesn’t display the items in an unordered list but just in plain text wrapped in spans. I guess it’s possible to modify the plugin although your way is an ingenious workaround for it
p/s: Dugg!
Friday, April 10th, 2009 at 9:09 am
This is great, but I have problem. How to show more than one category? Post is posted under 3 categories so how to show more than one category in breadcrumbs navigation bar? Thanks
Trackbacks/Pingbacks
Leave A Comment
Become one of our
Featured Sites
Recent Trackbacks
Contributing Authors
Archives
Extras
WordPress Hacks Copyright © 2007-2009 | An Apricot Media Website
Template by StudioPress | Custom Design by Kyle Eslick and Blog Design Studio
RSS Feed Email RSS