Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#19757 closed defect (bug) (wontfix)

the_category() should include depth

Reported by: jordash56 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


I've noticed a lot of category functions don't have depth attributes built into them.

The default usage of the_category() results in poorly formatted category listings for more complicated category structures (using Wordpress as a CMS).

Here's an example: http://bestappsrated.com/android-apps/

If you look at some of the post listings, you'll notice each category is duplicated, that's because their is 3 levels (depth) to that post.

If there was a depth option for the the_category()

for example allowing: the_category(', ', 'depth=2')

It would completely circumvent that problem, And allow a huge amount of flexibility and greater use of Categories withing wordpress, without forcing themer writing custom loops and for statements.

Here's another article where there's frustration that this function (and similar category functions) doesn't have a depth parameter: http://www.wpbeginner.com/wp-themes/how-to-display-only-parent-category-in-your-wordpress-post-loop/

Change History (5)

comment:1 @scribu4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

From the looks of it, it seems that you have that post assigned to the parent categories as well, which is not necessary.

Assign it only to the leaf categories and the problem goes away.

comment:2 @scribu4 years ago

Actually, I see what you mean. Still, a better solution would be to define multiple taxonomies:

  - iPhone
  - Android

Game type:
  - RPG
  - shooter

This way, you don't have to create duplicate terms.

Last edited 4 years ago by scribu (previous) (diff)

comment:3 @jordash564 years ago

Oh yeah you're right, that would be much better. And I realized, with 3 depths to the categories, there would still be duplicates even if depth was included in the_category.

I think i'll give the plugin: http://wordpress.org/extend/plugins/simple-taxonomies/installation/ that you recommend a try.


comment:4 @nacin4 years ago

There are also other template functions that can help generate lists and trees.

comment:5 @jordash564 years ago

Do you have any examples of the functions to generate lists and trees? Sounds Interesting.

I like the taxonomy method now, it's a lot more flexible, I applied it to pages like this:


It's not quite perfect though, the only way I could figure out how to do combined filters was with Scribus Multi Query plugin, it's almost perfect, I can do search terms like this:


But it's not fully search engine friendly in the URL, and it requires some custom way to program to get it easier for the user to navigate and take advantage of the filters. (Mainly a way to keep the query strings right).

I think Wordpress is definitely in the right direction in the Taxonomy methods, Drupal has some stuff like this built in and Wordpress is already almost better in that arena. (Plus wordpress is way better at everything else).

Note: See TracTickets for help on using tickets.