Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Here is my code:

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();
        if (is_single()) {
            echo " / ";
            the_title();
        }
    } 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
1  
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

1 Answer 1

Without a plugin, I found a nice, probably complete breadcrumb solution here:

How To Add WordPress Breadcrumbs Without a Plugin

It has it's own style solution too.

share|improve this answer
    
almost same problem, it shows a list of sub-cat for three times :( –  James Xu Jul 17 '13 at 1:51
    
Answer with link only isn't very good answer ;) –  Krzysiek Dróżdż Jul 17 '13 at 5:37
    
@KrzysiekDróżdż: I know. But it's one of the complete structure worked for me. Though I din't tried with sub-sub-sub categories. –  Mayeenul Islam Jul 17 '13 at 6:03

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.