Support » Requests and Feedback » wp_list_categories needs a child depth argument

  • I have requested this before but nothing official .. so here is the official request;

    The WP_LIST_CATEGORIES function seriously needs some form of child depth argument such that I can limit the number of children that show up.

    My theme is designed such that you get the Parent category, and one layer of children. Childrens Children shouldn’t show up. This is exactly how I want it.

    What I propose is a simple flag in the wp_list_categories function that says how deep to go.


    Depth=0 :: Default – show everything as you do now.
    Depth=1 :: show only the top level of categories, no children.
    Depth=2 :: show the top level of categories, and their children.
    Depth=3 :: Show the top level of categories, their children and their children’s children..


    This would easily work with the child_of argument and allow users more customization when it comes to how they want things displayed.


Viewing 8 replies - 1 through 8 (of 8 total)
  • Michael, looking at that .diff file that was submitted.. Is that the only change required to make this work the way I suggested?

    There isn’t much there change wise. Which implies that either the functionality is there completely already, OR the ticket you posted doesn’t reflect my suggestion..


    I didn’t create that trac ticket. That change has NOT been committed to the core code as of yet. If you want to try it then do so and please comment back on that trac ticket that the change did work (or didn’t work). Use your forum login/password to login to trac.

    Please backup existing files before changing.

    I’ll look at it shortly, but from that code change it looks like $depth can either be 0 or -1 which really doesn’t solve anything. But that’s just my looking at the .diff, not the code.

    If the change doesn’t work or you feel it should work ‘more better’, please suggest that on that trac ticket.

    Okay I’ll dig into it after lunch and see.. I need to make sure that “intoxination” is trying to do the same thing I suggest.. Right now I’m thinking he’s got something else in mind..

    Okay it appears everything was there except one minor detail.. It just didnt listen to the users argument. Thus;

    diff category-template.php category-template.php.bak 
    <               'echo' => 1, 'depth' => 0
    >               'echo' => 1
    <                       $depth = $r['depth'];  // Walk requested depth (0 being full depth).
    >                       $depth = 0;  // Walk the full depth.

    I updated the ticket (sorry for the mess)..

    With that one little change, that ticket can probably be closed.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘wp_list_categories needs a child depth argument’ is closed to new replies.