[wp-trac] [WordPress Trac] #29839: Enhance get_terms to return only bottom child terms (terms without children) when taxonomy is heirarchical

WordPress Trac noreply at wordpress.org
Sun Nov 16 19:52:28 UTC 2014


#29839: Enhance get_terms to return only bottom child terms (terms without
children) when taxonomy is heirarchical
---------------------------------+-----------------------------
 Reporter:  theMikeD             |       Owner:
     Type:  enhancement          |      Status:  new
 Priority:  normal               |   Milestone:  Future Release
Component:  Taxonomy             |     Version:  4.0
 Severity:  normal               |  Resolution:
 Keywords:  4.2-early has-patch  |     Focuses:
---------------------------------+-----------------------------
Changes (by boonebgorges):

 * keywords:  4.2-early good-first-bug has-patch => 4.2-early has-patch


Comment:

 >  Is there an option on $this->factory->term->create to return the term
 object rather than the id?

 `$this->factory->term->create_and_get()` should work. But, I think the
 problem is not that `wp_set_object_terms()` expects slugs for non-
 hierarchical taxonomies; I think it's that the `term_exists()` check in
 that function will only work for a term_id if it's passed as an integer,
 and you were probably passing '5' instead of `5`. Just a guess :)

 One last (I think last!) request. We generally try to avoid single unit
 test methods that do so much assertion. In the cases where you're using
 the same data, go ahead and keep the methods together. But when you switch
 to the non-hierarchical taxonomy, could you please start a new test method
 for that? So something like `test_childless_for_hierarchical_taxonomy()`
 and `test_childless_for_non_hierarchical_taxonomy()`. Then I think we're
 pretty much good, and we'll get this in as soon as 4.1 has been released.
 Thanks for your work on it!

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


More information about the wp-trac mailing list