EducateYourself
EducateYourself

Reputation: 979

wordpress - display parent category of selected one

I could display the selected category name in the following way:

    <?php if (have_posts()) :
    single_cat_title();
    while (have_posts()) : the_post();?>
...

The problem is that I cannot display parent category name of selected category as well. Could you please help me.

Upvotes: 1

Views: 283

Answers (1)

ham-sandwich
ham-sandwich

Reputation: 4050

You could use the get_category_parents() helper function.

<?php if (have_posts()) :
single_cat_title();
while (have_posts()) : the_post();
echo get_category_parents($cat, TRUE, ' &raquo; ');
?>

You would want to do this in the loop, rather than above it.

Upvotes: 1

Related Questions