Adding Microformatted Breadcrumbs to Thesis

by on December 19, 2011

Pin It

I received an email the other day asking how I added my breadcrumbs to my Thesis site.

On the site, they look like this:

Microformat Breadcrumbs

Microformat Breadcrumbs

But in the search results, they appear like this:

Thesis RDF Breadcrumbs

Breadcrumbs in Search Results

In the search results, the title is linked to the blog post, while the category is linked to the category page.

Here’s how I do it in Thesis

In custom_functions.php, I add the following function:

function breadcrumbs() {
	global $post;

	if (is_single()) {
		$aCategories = get_the_category($post->ID);
		?>
		<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb" id="breadcrumbs">
			You are here: <a href="http://www.ericnagel.com/" itemprop="url"><span itemprop="title">Eric Nagel</span></a> &gt;
			<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
				<a href="/category/<?= $aCategories[0]->slug ?>" itemprop="url"><span itemprop="title"><?= $aCategories[0]->name ?></span></a> &gt;
				<span itemprop="child" itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
					<a href="<?php the_permalink(); ?>" itemprop="url"><span itemprop="title"><?php the_title() ?></span></a>
				</span>
			</span>
		</div>

		<?php
	} // ends if (is_single())
} // ends function breadcrumbs()

And then I add the hook to call the function:

add_action('thesis_hook_before_post', 'breadcrumbs');

Of course, you’ll want to take out the references to “Eric Nagel” and ericnagel.com. Also, my category slug is “category” but you may have changed yours. If so, make that change (line 10)

Read more about breadcrumbs, or test your code using Google’s Rich Snippets Testing Tool

Was this post useful? Please share it with others:

Pin It

EricNagel.com runs on the Thesis WordPress Theme

Thesis Theme thumbnail

If you’re an affiliate who doesn’t understand a lot of PHP, HTML, or CSS, Thesis will give you a ton of functionality without having to alter any code. For the advanced, Thesis has incredible customization possibilities via extensive hooks and filters. And with so many design options, you can use the template over and over and never have it look like the same site.

If you’re more familiar with how websites work, you can use the fantastic Thesis User’s Guide and world-class support forums to make more professional customizations than you ever thought possible. The theme is not only highly customizable, but it allows me to build sites with a much more targeted focus on monetization than ever before. You can find out more about Thesis below:

{ 3 comments… read them below or add one }

James Seligman December 28, 2011 at 6:21 pm

Great Stuff! One question, Will this affect SEO after adding it to a site that’s already a few years old?

Reply

Eric Nagel December 29, 2011 at 1:22 pm

It shouldn’t negatively affect it. I can only see it helping, not hurting.

Reply

James Seligman December 29, 2011 at 7:57 pm

Okay, I’ll give it a try.

Reply

Leave a Comment

Previous post:

Next post: