Opened 8 years ago
Last modified 2 years ago
#44279 reopened defect (bug)
`get_terms()` with `child_of` and `childless` combined
| Reported by: | nonverbla | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Taxonomy | Version: | 4.9.6 |
| Severity: | normal | Keywords: | has-unit-tests needs-patch |
| Cc: | Focuses: |
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
@
2 years 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.
2 years ago
#4
@
2 years ago
- Milestone Awaiting Review
- Resolution → invalid
- Status new → 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.
2 years ago
#5
- Keywords has-patch has-unit-tests added
Trac ticket: https://core.trac.wordpress.org/ticket/44279
#6
@
2 years ago
- Keywords needs-patch added; has-patch removed
- Milestone → Future Release
- Resolution invalid
- Status closed → 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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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?