WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#12533 closed defect (bug) (fixed)

Parent term count

Reported by: jfarthing84 Owned by: filosofo
Milestone: 3.0 Priority: highest omg bbq
Severity: blocker Version: 3.0
Component: Taxonomy Keywords: has-patch commit
Focuses: Cc:

Description (last modified by dd32)

Hierarchical term parents (including categories) count stays at 0 when using child terms. This results in a 404 error when trying to pull up the term/category page for a parent term which has children with posts.


When viewing a Parent term of a custom taxonomy, Objects in the children of the term are not shown.

Attachments (4)

12533.diff (1.4 KB) - added by jfarthing84 7 years ago.
wp-includes/query.php
12533.2.diff (1.7 KB) - added by scribu 7 years ago.
bring in empty terms only for hierarchical taxonomies
12533.3.diff (5.3 KB) - added by scribu 7 years ago.
beautification
12533.4.diff (5.2 KB) - added by scribu 7 years ago.

Download all attachments as: .zip

Change History (24)

#1 @jfarthing84
7 years ago

It seems this is just affecting hierarchical custom taxonomies (which is still just as important).

#2 @jfarthing84
7 years ago

Upon even further investigation, if you pull up an empty custom taxonomy (hierarchical or not), you get a 404 error rather than the default page displaying "No posts found" which would display if you pulled up an empty category.

#3 @dd32
7 years ago

(In [13615]) Don't 404 for empty custom taxonomy terms. See #12533

#4 @Denis-de-Bernardy
7 years ago

  • Milestone changed from Unassigned to 3.0

#5 @jfarthing84
7 years ago

Thanks. You will also have to add the 'hide_empty=>false' flag to the is_tax section og WP_Query::get_queried_object().

Also, there still is a problem with custom hierarchical taxonomies.

#6 @dd32
7 years ago

Thanks. You will also have to add the 'hide_empty=>false' flag to the is_tax section og WP_Query::get_queried_object().

The changeset doesnt show it very well, but thats where it is.

Hierarchical term parents (including categories) count stays at 0 when using child terms.

This depends on if the arg 'pad_counts' is set or not, By default, its not. Where are you seeing it not being reported correctly?

#7 @jfarthing84
7 years ago

Forget the count. I was just saying, it is not taking child terms into account at all.

Look at how categories are handled and then look at how taxonomies are handled. You'll clearly see that the taxonomy handling lacks any support for hierarchical taxonomies.

#8 @dd32
7 years ago

  • Description modified (diff)
  • Keywords dev-feedback removed

Look at how categories are handled and then look at how taxonomies are handled. You'll clearly see that the taxonomy handling lacks any support for hierarchical taxonomies.

Are you saying, That visiting /tax/parent/ is not showing posts in /tax/parent/child/ too? - Sorry, I didnt quite understand that in the original ticket description.

Showing the children always confused me, but i can see why it would be required.

#9 follow-up: @jfarthing84
7 years ago

Yea, exactly.

Say you are using something like this:

United States

  • Alabama
  • Alaska
  • Etc...

In most cases, you will only assign a post to one of the child terms. Then, if you visit the parent term (you wanted to see all pots in the US), you should see ALL child posts.

#10 in reply to: ↑ 9 @scribu
7 years ago

  • Keywords needs-patch added

Replying to jfarthing84:

Say you are using something like this:

United States

  • Alabama
  • Alaska
  • Etc...

In most cases, you will only assign a post to one of the child terms. Then, if you visit the parent term (you wanted to see all pots in the US), you should see ALL child posts.

Agreed.

@jfarthing84
7 years ago

wp-includes/query.php

#11 @jfarthing84
7 years ago

  • Keywords has-patch added; needs-patch removed

#12 @sillybean
7 years ago

  • Cc steph@… added

#13 @jfarthing84
7 years ago

So, this is ready to go, no?

@scribu
7 years ago

bring in empty terms only for hierarchical taxonomies

@scribu
7 years ago

beautification

#14 @scribu
7 years ago

  • Keywords commit added

12533.2.diff:

  • bring in empty terms only for hierarchical taxonomies
  • replace a count() check with !empty()

12533.3.diff:

  • remove redundant whitespace

@scribu
7 years ago

#15 @scribu
7 years ago

Previous patches did not handle the case where $qtaxonomy? was empty.

This is fixed in 12533.4.diff

#16 @dd32
7 years ago

This is fixed in 12533.4.diff

Patch looks good overall, I'll add it to the testing queue.

#17 @dd32
7 years ago

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

(In [13787]) When viewing a Parent term in a hierarchical taxonomy, display objects contained within children too. Props scribu. Fixes #12533

#18 @scribu
7 years ago

It should have been "Props jfarthing84, scribu", since he submitted the initial patch. Oh well...

#19 @dd32
7 years ago

It should have been "Props jfarthing84, scribu",

My apologies to jfarthing84, I didnt realise he'd submitted the first patch when committing.

#20 @jfarthing84
7 years ago

I was going to say that. But yeah, "Oh well."

Note: See TracTickets for help on using tickets.