WordPress.org

Ready to get started?Download WordPress

Forums

Using wp_list_Categories to show only DIRECT children (2 posts)

  1. jugularbean
    Member
    Posted 7 years ago #

    I'm trying to acheive a category sidebar that shows the children of the current category.
    So for example if my cat structure is as follows
    Arts
    - Music
    -- Jazz
    -- Rock
    - Literature
    -- Poetry
    -- Prose

    When I am in the arts category page I want only Music, Literature to display in the sidebar
    And when I click on music then Jazz and rock will display.

    I'm currently using wp_list_categories("title_li=&child_of=$cat")
    But it lists the sub-sub-categories as well. IS there anyway I can disable that?

  2. murky
    Member
    Posted 7 years ago #

    I had a solution here:

    http://wordpress.org/support/topic/82359

    but it relies on deprecated tags, which isn't great.

    To me, options to show only the children and siblings of current categories should be available in the core (correctly embedded in a list showing the parents

    e.g.
    A
    B
    C
    (-Ca) <--not shown
    -Cb
    --Cbi <----current
    ---Cbi1 <--children (first generation only)
    ( ----Chi1a ) <-- not shown
    ---Cbi2
    --Cbj <----sibling
    (-Cc) <-- not shown
    D
    E

    E.g if viewing Cbi we'd have the options to see this:
    A
    B
    C
    -Cb
    --Cbi <----current
    ---Cbi1
    ---Cbi2
    --Cbj
    D
    E

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags