Breadcrumbs for Taxonomy Pages

I'm working on a project right now that uses hierarchical taxonomies, and here's the solution I used for taxonomy breadcrumbs.

I'm working on a project right now that uses hierarchical taxonomies, and the client requested a breadcrumb along the top. I searched online but couldn't find any good existing plugins, so thought I'd write my own.

Note: This was built for WordPress 3.03. WordPress 3.1 (hopefully coming out this month) will add a lot of features to taxonomies, including hierarchical URLs. This solution is NOT designed for hierarchical URLs. If you read through the code you'll see I'm assembling them with 3 things:

  • bloginfo('url') - This is the URL for your site
  • $item->taxonomy - This is the name of the taxonomy the term is in
  • $item->name - This is the name of the taxonomy term

Since WordPress doesn't currently support hierarchical URLs for taxonomies, no matter how deep your term is it will still have the url structure of yoursite.com/taxonomy-name/taxonomy-term. Hopefully 3.1 will give us a URL from get_term_by(), but it doesn't now, which is why I did it this way.

With that said, here's the code. Place this in your functions.php file (or custom_functions.php for Thesis):

https://gist.github.com/billerickson/1325540

To use it in your theme, simply call be_taxonomy_breadcrumb() within a <ul>

No comments yet