WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my code:

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

It gives a wrong result:

website name > cat1 > cat1 sub1 > cat1 sub2 > cat1 sub3 > your location

The order I try to get:

home >cat1 > cart1 sub1 >your location

Can someone tell me what I have to change?

share|improve this question
What categories is this post assigned to? – Krzysiek Dróżdż Jul 16 '13 at 7:01
i use <?php the_breadcrumb(); ?> in a sub categories page.single-new.php. I have several single pages. – James Xu Jul 16 '13 at 7:54
That is not answer to my question ;) You gave example of wrong breadcrumbs website name > cat1 > cat1 sub1 > cat1 sub2 > cat1 sub3 > your location. So what categories is this post assigned to? If post is assigned to many categories, then which one of them would you like to see n breadcrumbs? – Krzysiek Dróżdż Jul 16 '13 at 8:04
a little bit confused. I assigned it to cat1 sub2 – James Xu Jul 17 '13 at 1:46
So it's assigned to only one category? It's a little bit strange - the_category returns 4 categories... Where are you calling this the_breadcrumb function? Outside the loop, I guess? – Krzysiek Dróżdż Jul 17 '13 at 5:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.