[wp-trac] [WordPress Trac] #37728: hide_empty doesn't work correctly in get_terms when no taxonomy specified

WordPress Trac noreply at wordpress.org
Thu Aug 1 21:33:07 UTC 2019


#37728: hide_empty doesn't work correctly in get_terms when no taxonomy specified
-------------------------------------------------+-------------------------
 Reporter:  smerriman                            |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Taxonomy                             |     Version:  4.5
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-unit-tests           |     Focuses:
  reporter-feedback needs-testing                |
-------------------------------------------------+-------------------------
Changes (by smerriman):

 * keywords:  has-patch needs-unit-tests reporter-feedback close needs-
     testing => has-patch needs-unit-tests reporter-feedback needs-testing


Comment:

 Have just run into this bug on another site I'm working on. I wanted to
 list all subcategories of a parent category, so used:

 `$terms = get_terms(array('child_of'=>1));`

 but was returned an empty array, because posts only exist in the
 subcategories, and none directly in the parent category.

 In this case, I could add the taxonomy parameter to fix it:

 `$terms = get_terms(array('child_of'=>1,'taxonomy'=>'category'))`

 But it would be nice if this bug can be resolved, given I reported it,
 along with a trivial one line fix, 3 years ago.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/37728#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list