Opened 7 months ago

Last modified 2 months ago

#22208 new enhancement

get_children() doesn't support 'fields' => 'ids' as an argument

Reported by: danielbachhuber Owned by:
Priority: normal Milestone: Awaiting Review
Component: Query Version: 3.4.2
Severity: normal Keywords: dev-feedback has-patch
Cc:

Description

Not sure whether it should, but it would be nice.

When you pass 'fields' => 'ids' as an argument, the data returned by get_posts() is nooped with this block:

foreach ( $children as $key => $child )
    $kids[$child->ID] = $children[$key];

Attachments (1)

22208.diff (369 bytes) - added by Jesper800 2 months ago.

Download all attachments as: .zip

Change History (3)

  • Keywords needs-patch added
  • Type changed from defect (bug) to enhancement
  • Version set to 3.4.2
  • Keywords has-patch added; needs-patch removed

I've added a patch that checks whether the fields parameter is set to either ids or id=>parent, in which case it returns the result from get_posts. Please note that if this is the case, the $output parameter will have no effect. This is something to consider, as it does make the functionality a bit confusing.

Another option would be to ignore the fields parameter for this function and add documentation for that, but it does break functionality currently.

Last edited 2 months ago by Jesper800 (previous) (diff)
Note: See TracTickets for help on using tickets.