• Resolved gashface

    (@gashface)


    Is there a way to list the parent category with the child categories? I am currently trying to create a sidebar that looks something like this:

    Parent Category
    Child Cat 1
    Child Cat 2
    Child Cat 3

    However I can only find listing codes that either list the parent category or the children.

    <?php wp_list_categories('use_desc_for_title=0&child_of=24'); ?>

    The code above I’m using I tried adding include=24& but that did nothing, also how do I get rid of the title ‘categories’ I tried the usual title=li but that didn’t work either.
    Any help appreciated, thankyou!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Use this:

    <?php wp_list_categories('include=24,'.implode(',',get_term_children(24, 'category')).'&title_li='); ?>

    Thread Starter gashface

    (@gashface)

    thankyou that worked perfectly!

    Thread Starter gashface

    (@gashface)

    One more question, as a bonus. I’m using current-cat to highlight the current category as a different colour.

    On the parent it highlights all of the children as well, is there a way that on the parent category page it will only highligh the parent in the list or not?

    Two easier methods I can think of:

    1. Depending on how it’s highlighted, you can write the CSS so that it “un-highlight” the children because the children categories are a list within a list.

    2. If the parent category is created before the children (lower integer ID), you can make it so that the children are not a list within the parent by setting

    hierarchical=0
    orderby=ID

    Note that the children categories will no longer be listed alphabetically after the parent unless they were created in an alphabetical order.

    Fank you and me helped

    Thread Starter gashface

    (@gashface)

    This works in CSS:

    #sidebar li.current_page_item a{color: #00ADEE;}
    #sidebar ul.children a{margin: 0px 0px 0 20px; #808184;}

    (:

    thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘List parent category with child categories?’ is closed to new replies.