WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_categories needs a child depth argument (9 posts)

  1. palamedes
    Member
    Posted 6 years ago #

    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.

    Argument:

    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..

    etc..

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

    Thoughts?

  2. MichaelH
    Member
    Posted 6 years ago #

  3. palamedes
    Member
    Posted 6 years ago #

    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..

    Thoughts?

  4. MichaelH
    Member
    Posted 6 years ago #

    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.

  5. palamedes
    Member
    Posted 6 years ago #

    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.

  6. MichaelH
    Member
    Posted 6 years ago #

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

  7. palamedes
    Member
    Posted 6 years ago #

    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..

  8. palamedes
    Member
    Posted 6 years ago #

    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 
    
    253c253
    <               'echo' => 1, 'depth' => 0
    ---
    >               'echo' => 1
    
    292c292
    <                       $depth = $r['depth'];  // Walk requested depth (0 being full depth).
    ---
    >                       $depth = 0;  // Walk the full depth.

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

  9. palamedes
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic