Opened 6 years ago
Closed 5 years ago
#46768 closed defect (bug) (fixed)
Not working get_terms with parameters 'child_of' and 'fields'=>'id=>name'
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | 3.7 |
Component: | Taxonomy | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
When I tried select all child terms from my category I had an error
PHP Notice: Undefined property: stdClass::$parent in /wp-includes/taxonomy.php on line 3529
I used
$terms = get_terms(
['taxonomy' => 'my_taxonomy_name',
'child_of' => TERM_ID,
'fields' => 'id=>name']
);
And I have empty result and notice on logs.
If I remove parameter "fields", it works fine.
Or if change 'fields' to 'ids' or 'names'.
Attachments (2)
Change History (8)
#1
@
6 years ago
- Keywords needs-unit-tests added
- Milestone changed from Awaiting Review to Future Release
- Version changed from trunk to 3.7
#2
@
5 years ago
- Keywords has-patch added; needs-patch removed
The names
fields param already accounts for grabbing the tt.parent. I don't see why we can't do the same for both id=>name
and id=>slug
. I've added a patch that simply adds these in which should address the issue.
This ticket was mentioned in Slack in #core by howdy_mcgee. View the logs.
5 years ago
#4
@
5 years ago
- Milestone changed from Future Release to 5.5
- Owner set to SergeyBiryukov
- Severity changed from major to normal
- Status changed from new to reviewing
Note: See
TracTickets for help on using
tickets.
Hi @planvova, welcome to WordPress Trac! Thanks for the report.
Introduced in [25161].