Make WordPress Core

Opened 11 years ago

Closed 8 years ago

#15919 closed defect (bug) (fixed)

wp_count_terms() hide_empty not working

Reported by: zeo Owned by: markjaquith
Milestone: 3.7 Priority: high
Severity: major Version:
Component: Taxonomy Keywords: has-patch 3.7-early
Focuses: Cc:


For tax category, wp_count_terms( 'category', array( 'hide_empty' => true ) ) returns all category and doesn't hide category with post count 0. Instead need to use wp_count_terms( 'category', array( 'hide_empty' => true, 'hierarchical' => false ) ).

Since hide_empty=false is the default args, wp_count_terms() should set hierarchical=false by default too.

Attachments (4)

15919.diff (353 bytes) - added by zeo 11 years ago.
15919.002.diff (392 bytes) - added by markjaquith 11 years ago.
patch at a deeper level
15919.2.diff (392 bytes) - added by wonderboymusic 9 years ago.
15919_3.diff (446 bytes) - added by faishal 9 years ago.
updated patch

Download all attachments as: .zip

Change History (16)

11 years ago

#1 @markjaquith
11 years ago

  • Milestone changed from Awaiting Review to 3.1
  • Owner set to markjaquith
  • Status changed from new to accepted

Bug reproduced. Patch fixes it.

Last edited 11 years ago by markjaquith (previous) (diff)

#2 @scribu
11 years ago

Is this a regression?

#3 @dd32
11 years ago

  • Component changed from General to Taxonomy

#4 @markjaquith
11 years ago

  • Keywords 3.2-early added
  • Milestone changed from 3.1 to Future Release
  • Priority changed from normal to high
  • Severity changed from normal to major

This is not a regression from 3.0, so I'm going to do it 3.2-early.

11 years ago

patch at a deeper level

#5 @SergeyBiryukov
10 years ago

Closed #19340 as a duplicate.

#6 @wonderboymusic
9 years ago

  • Milestone changed from Future Release to 3.6

Refreshed against trunk just so the line numbers match - this is from the class of 3.2-early

9 years ago

updated patch

#7 @faishal
9 years ago

  • Keywords 3.2-early removed

#8 @SergeyBiryukov
9 years ago

Generally, a refresh is only needed when the patch no longer applies cleanly.

Line numbers may be off, but as long as the content is the same, the patch should still apply cleanly. 15919.002.diff is still fine.

Also, when copying code directly from Trac, make sure to remove trailing whitespace.

Last edited 8 years ago by SergeyBiryukov (previous) (diff)

#9 @nacin
8 years ago

  • Keywords 3.7-early added
  • Milestone changed from 3.6 to Future Release

#10 @wonderboymusic
8 years ago

  • Milestone changed from Future Release to 3.7

#11 @wonderboymusic
8 years ago

these are all marked 3.7-early

#12 @wonderboymusic
8 years ago

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

In 25551:

Ensure that terms with a post count of 0 are not returned in wp_count_terms() when hide_empty => true. Adds unit test which ensures that wp_count_terms() returns 0.

Props markjaquith.
Fixes #15919.

Note: See TracTickets for help on using tickets.