Full Breadcrums, how to?

Hi there, I’m trying to get a full breadcrumb in my theme, so it will be like this: Home > Parrent Category > Sub Category > Product.

Ive tried to make abit of a function but the the_category doesnt work, heres what ive made:

function the_breadcrumb() {
if (!is_home()) {
echo '<a href="';
echo get_option('home');
echo '">';
bloginfo('name');
echo "</a> » ";
if (is_category() || is_single()) {
the_category('title_li=');
if (is_single()) {
echo " » ";
the_title();
}
} elseif (is_page()) {
echo the_title();
}
}
}

If any1 got a piece of code or can help me build my own that would be great. Cheers

  • AbleReach
    • Flash Drive

    If you don’t mind using a plugin, you might try NavXT. They’ve been around a long time and still have an active support presence on their blog. Complaints are mainly related to the fact that it will kick up an error if you aren’t using the recent PHP & mySQL – then again, so will the upcoming WP 3.2. Pay no attention to upgrade haters.

    The first time I used NavXT I was just getting used to the idea that I might be able to look at source code and see what it does. :slight_smile: Even if you don’t want to use a plugin, it might be worth installing one to peek at the code and see how it works.

  • DavidM
    • DEV MAN’s Mascot

    @ablereach, that’s a great suggestion I’d say, since the plugin appears to support custom post types, which I believe is the issue in this case. I haven’t tried it myself but it looks very nice.

    @epenance, I believe the issue is simply that this is regarding a custom post type, and is_category() is meant distinctly for regular posts. I think what you’d want is is_tax() instead.

    http://codex.wordpress.org/Function_Reference/is_tax

    And as for the display of the taxonomy (category) I believe you’ll want to use the following:

    http://codex.wordpress.org/Function_Reference/get_the_term_list

    You might also be interested in using is_singular( ‘product’ ) also.

    Hope that helps!

    -David

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.