Ticket #2461 (closed enhancement: fixed)

Opened 6 years ago

Last modified 4 years ago

Add ability to limit depth of tree produced by wp_list_categories()

Reported by: researcher Owned by: pishmishy
Priority: normal Milestone: 2.5
Component: Template Version: 2.0.1
Severity: normal Keywords: wp_list_categories has-patch
Cc:

Description

the catstructure in WP is well known i think:

Parent1
 - Child1A
 - Child1B
Parent2
 - Child2A
 - - Child2A1
 - - CHild2A2

and so on. if Parent2 is chosen with list_cats() you get also all the Children2XX. there is no logic in this from users perspective (if i call Matt, i don't wont to speak to his 12 children! sorry Matt).

my suggestion is; create 3 entities.

first entity = ThisCat     (the current category and show all posts)
second      = ParentCat  (should be turned ON or OFF, shows posts in the ParentCat YES or NO)
third         = ChildCat    (should be turned ON or OFF, shows posts in the ChildCat YES or NO)

Attachments

2461.patch Download (698 bytes) - added by pishmishy 4 years ago.
Allows depth of tree walk to be set
2461-2.patch Download (709 bytes) - added by pishmishy 4 years ago.
Patch for wp_dropdown_categories()

Change History

comment:1   matt5 years ago

  • Status changed from new to closed
  • Resolution set to invalid

Sorry, I don't understand this.

  • Status changed from closed to reopened
  • Resolution invalid deleted

I'm not sure about the suggested solution, but I share the problem...

Essentially, WP category listing can be very bloated for the end user.

Parent1

  • Child1A
  • Child1B

Parent2

  • Child2A
  • - Child2A1
  • - CHild2A2

If viewing Parent2, it should be possible to make the ONLY child to be visible should be Child2A (or 2B etc)

I would like options to 1) show all parent categories (relevant if in a subcategory page) 2) show the parents of the current category (in the correct places, see below) 3) Show first children of current category 4) show sibling categories 5) An optional user controllable string could be tagged on if there were undisplayed children categories (default would be [+] ) 6) The current category would be displayed with no link on it (allowing for css selection)

So with this structure:

Parent1

  • Child1A
  • - Child 1A1
  • - Child 1A2
  • - - Child 1A2A
  • Child1B

Parent2

  • Child2A
  • - Child2A1
  • - - Child2A1A
  • - CHild2A2
  • - - Child2A2A

Parent3

  • Child3A
  • - Child3A1
  • - CHild3A2

Suppose we looked at CHild2A2, it should be possible to display:

Parent1[+] Parent2

  • Child2A
  • - Child2A1[+]
  • - CHild2A2
  • - - Child2A2A <--- no link for this cat

Parent3[+]

Much neater.... and easier to navigate.

Oops, for some reason Parent 1 and 2 got put on the same line... apologies.

  • Milestone changed from 2.1 to 2.4 (future)
  • Type changed from defect to enhancement
  • Summary changed from Categories and Posts, Parents and Children not separated in list_cats() to Add ability to limit depth of tree produced by list_cats()

Reading over the ticket I believe this to be a more accurate description.

  • Summary changed from Add ability to limit depth of tree produced by list_cats() to Add ability to limit depth of tree produced by wp_list_categories()

Oh and list_cats() is depreciated so...

Allows depth of tree walk to be set

  • Keywords wp_list_categories has-patch added; list_cats removed
  • Owner changed from anonymous to pishmishy
  • Status changed from reopened to new

Trivial patch allows depth of tree walk to be set manually by the theme author. Defaults to existing value of 0. Documentation will need updating if it is decided to commit this patch.

Does a similar option need to be included for other tree walks?

  • Status changed from new to assigned

This might have been addressed here;

 http://trac.wordpress.org/ticket/5004

(In [6595]) Add depth arg to wp_list_categories(). Props pishmishy. see #2461

wp_dropdown_categories() could use the same thing.

Patch for wp_dropdown_categories()

Ryan, patch for wp_dropdown_categories() now attached. Once applied, please close.

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [6690]) Add depth arg to wp_dropdown_categories(). Props pishmishy. fixes #2461

Note: See TracTickets for help on using tickets.