WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 7 months 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:

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

Download all attachments as: .zip

Change History (16)

zeo3 years ago

comment:1 markjaquith3 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 3 years ago by markjaquith (previous) (diff)

comment:2 scribu3 years ago

Is this a regression?

comment:3 dd323 years ago

  • Component changed from General to Taxonomy

comment:4 markjaquith3 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.

markjaquith3 years ago

patch at a deeper level

comment:5 SergeyBiryukov2 years ago

Closed #19340 as a duplicate.

wonderboymusic16 months ago

comment:6 wonderboymusic16 months 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

faishal13 months ago

updated patch

comment:7 faishal12 months ago

  • Keywords 3.2-early removed

comment:8 SergeyBiryukov12 months 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 10 months ago by SergeyBiryukov (previous) (diff)

comment:9 nacin10 months ago

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

comment:10 wonderboymusic9 months ago

  • Milestone changed from Future Release to 3.7

comment:11 wonderboymusic9 months ago

these are all marked 3.7-early

comment:12 wonderboymusic7 months 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.