WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 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 5 years ago.
wp-includes/query.php
12533.2.diff (1.7 KB) - added by scribu 5 years ago.
bring in empty terms only for hierarchical taxonomies
12533.3.diff (5.3 KB) - added by scribu 5 years ago.
beautification
12533.4.diff (5.2 KB) - added by scribu 5 years ago.

Download all attachments as: .zip

Change History (24)

comment:1 @jfarthing845 years ago

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

comment:2 @jfarthing845 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.

comment:3 @dd325 years ago

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

comment:4 @Denis-de-Bernardy5 years ago

  • Milestone changed from Unassigned to 3.0

comment:5 @jfarthing845 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.

comment:6 @dd325 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?

comment:7 @jfarthing845 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.

comment:8 @dd325 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.

comment:9 follow-up: @jfarthing845 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.

comment:10 in reply to: ↑ 9 @scribu5 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.

@jfarthing845 years ago

wp-includes/query.php

comment:11 @jfarthing845 years ago

  • Keywords has-patch added; needs-patch removed

comment:12 @sillybean5 years ago

  • Cc steph@… added

comment:13 @jfarthing845 years ago

So, this is ready to go, no?

@scribu5 years ago

bring in empty terms only for hierarchical taxonomies

@scribu5 years ago

beautification

comment:14 @scribu5 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

@scribu5 years ago

comment:15 @scribu5 years ago

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

This is fixed in 12533.4.diff

comment:16 @dd325 years ago

This is fixed in 12533.4.diff

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

comment:17 @dd325 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

comment:18 @scribu5 years ago

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

comment:19 @dd325 years ago

It should have been "Props jfarthing84, scribu",

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

comment:20 @jfarthing845 years ago

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

Note: See TracTickets for help on using tickets.