Opened 6 years ago
Last modified 8 months ago
#44279 reopened defect (bug)
`get_terms()` with `child_of` and `childless` combined
Reported by: | nonverbla | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 4.9.6 |
Component: | Taxonomy | Keywords: | has-unit-tests needs-patch |
Focuses: | Cc: |
Description
Hi there! I'm not sure if I found a bug or this is intended behaviour: If I use a combination of childless
and child_of
in a get_terms
call, I get zero results.
My taxonomy's structure:
- Genre -- Hip Hop -- Trap -- Rap - Location -- Europe --- Germany --- Sweden --- Austria -- Asia --- China --- Japan --- Taiwan
My code:
<?php $location_parent = get_term(123, 'my_custom_taxonomy'); $countries = get_terms(array( 'taxonomy' => $location_parent->taxonomy, 'hide_empty' => false, 'child_of' => $location_parent->term_id, 'childless' => true ));
I'm trying to only list countries, basically children of 'location' that don't have children of their own.
Attachments (1)
Change History (7)
#2
@
8 months ago
- Keywords reporter-feedback removed
Sorry @boonebgorges, I absolutely missed that this ticket got a reply 6 years ago!! If there is a passing unit test already in place, I'm trusting that much more than myself.
This ticket was mentioned in Slack in #core by nonverbla. View the logs.
8 months ago
#4
@
8 months ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
I am closing this ticket because this issue is not replicated so far and this case is covered by Unit tests.
This ticket was mentioned in PR #6201 on WordPress/wordpress-develop by @jorbin.
8 months ago
#5
- Keywords has-patch has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/44279
#6
@
8 months ago
- Keywords needs-patch added; has-patch removed
- Milestone set to Future Release
- Resolution invalid deleted
- Status changed from closed to reopened
I think that the test doesn't actually show the case described in the ticket so I updated it.
The test originally demonstrated direct children, but not all levels of children. To use the locations example, the test would return Antarctica which has no nations.
Hi @nonverbla - Thanks for the ticket. I'm unable to reproduce the problem with a unit test - see 44279.test.diff, which is passing. Can you have a look at that test to see if I've accurately captured what you're describing?