The code below automatically selects the breadcrumb trail for the category, and custom taxonomy. Unfortunately there wasn't a lot of documentation on it, yet.
Soooo.... Without further ado.
The most important bit for me was how to figure out, how to choose a custom taxonomy term automatically, based on the taxonomy term url. As well as how to get the url of just a parent category.
The breadcrumb trail has the custom taxonomy term after a parent category:
So Home -> Parent category -> Taxonomy term
You might also be able to do it as:
Home -> Custom taxonomy -> Taxonomy term
However when I tried this and linked to blog.com/custom_taxonomy, the link gave a 404 error. As I am using a different set-up (category -> taxonomy term) in the first place, and doing url rewriting in both the theme and the Apache paths, it is not something I need at the the moment so did not spent a lot of time trying to figure out. So, YMMV.
Feel free to improve and customize. This is a beta code snippet. Use at your own risk. I would not use this code snippet on a live site yet. The code is more meant for people trying to figure their way out in coding with automatic category/ custom taxonomies selection and breadcrumbs, and to build from there if and when needed.
Code:
`
<?php
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
$tax_term_breadcrumb_term_slug = $term->slug;
$tax_term_breadcrumb_taxonomy_slug = $term->taxonomy;
foreach (get_the_category() as $cat) {
$parent = get_category($cat->category_parent);
$parent_name = $parent->cat_name;
$parent_slug = $parent_name;
$parent_slug = strtolower(str_replace("(","",$parent_slug));
$parent_slug = str_replace(')',' ', $parent_slug);
$parent_slug = str_replace(' ','-', $parent_slug);
}
if ( is_category($parent_name) ) { ?>
/" title="Home">Home » <? echo $parent_name; ?>
<?php } elseif (is_tax($tax_term_breadcrumb_term_slug)) { ?>
/" title="Home">Home » /<? echo $parent_slug ?>" title="<? echo $parent_name;" ?>"><? echo $parent_name; ?> » <?php echo $term->name; ?>
<?php } elseif ( is_front_page() ){ ?>
Home
<? } ?>
Hope it helps. :-)