Make WordPress Core

Opened 16 years ago

Closed 13 years ago

#15919 closed defect (bug) (fixed)

wp_count_terms() hide_empty not working

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

Description

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 16 years ago.
15919.002.diff (392 bytes ) - added by markjaquith 16 years ago.
patch at a deeper level
15919.2.diff (392 bytes ) - added by wonderboymusic 14 years ago.
15919_3.diff (446 bytes ) - added by faishal 13 years ago.
updated patch

Download all attachments as: .zip

Change History (16)

@zeo
16 years ago

#1 @markjaquith
16 years ago

  • Milestone Awaiting Review3.1
  • Owner set to markjaquith
  • Status newaccepted

Bug reproduced. Patch fixes it.

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

#2 @scribu
16 years ago

Is this a regression?

#3 @dd32
16 years ago

  • Component GeneralTaxonomy

#4 @markjaquith
16 years ago

  • Keywords 3.2-early added
  • Milestone 3.1Future Release
  • Priority normalhigh
  • Severity normalmajor

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

@markjaquith
16 years ago

patch at a deeper level

#5 @SergeyBiryukov
15 years ago

Closed #19340 as a duplicate.

#6 @wonderboymusic
14 years ago

  • Milestone Future Release3.6

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

@faishal
13 years ago

updated patch

#7 @faishal
13 years ago

  • Keywords 3.2-early removed

#8 @SergeyBiryukov
13 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 13 years ago by SergeyBiryukov (previous) (diff)

#9 @nacin
13 years ago

  • Keywords 3.7-early added
  • Milestone 3.6Future Release

#10 @wonderboymusic
13 years ago

  • Milestone Future Release3.7

#11 @wonderboymusic
13 years ago

these are all marked 3.7-early

#12 @wonderboymusic
13 years ago

  • Resolutionfixed
  • Status acceptedclosed

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.