Ready to get started?Download WordPress


Show parent categories when only children categories are selected (1 post)

  1. inteli6encia
    Posted 7 years ago #


    I use hierarchical categories, and I'd like to show parent categories in the list of categories (in the sidebar) even when the post have set only children categories.

    Example: I have the parent category "Food and beverages" and the children category "Liqueurs". I write a post about aniseed liqueur and set only the category "Liqueurs" for it. In my sidebar (where the category list is set to be shown) nothing appears: not "Food and beverages" and even not "Liqueurs".

    As I can see, the default behaviour of the function wp_list_cats() with argument hierarchical activated, is not show parent nor childrens if at least one post hasn't the parent set. If I not use hierarchical, the children is shown.

    Do you know some workaround, hack, etc., to show parent categories in the list of categories even when the posts have set only children categories? I know some of PHP and I can start modify the function wp_list_cats() myself, but maybe somebody has done it and I not need to "reinvent the wheel".

    Another options for me is open each post, one by one, and set the parent categories, one by one... Interesting but too much time-consuming. That's another reason why I vote for the idea of a method where you could mass-set categories at once but, even if implemented, I must wait for it.

    Any help will be very appreciated. Thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic