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.

I'm using a custom breadcrumbs (without plugin), and it outputs like this:

Home > Category > Post Name

So far so good, but there are posts with more than one category, so I was trying to modify it to look like:

Home > Category 1, Category 2 > Post Name

Here's the corresponding piece of code:

    $cat = get_the_category(); $cat = $cat[0];  
    $cats = get_category_parents($cat, TRUE, $delimiter);  
    if ($show_current == 0) $cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats);  
    $cats = str_replace('<a', $link_before . '<a' . $link_attr, $cats);  
    $cats = str_replace('</a>', '</a>' . $link_after, $cats);  
    if ($show_title == 0) $cats = preg_replace('/ title="(.*?)"/', '', $cats);  
    echo $cats;  
    if ($show_current == 1) echo $before . get_the_title() . $after;

And here is the full code

Thanks!

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.