Opened 8 years ago
Closed 6 years ago
#44305 closed defect (bug) (fixed)
The 'fields' query parameter for WP_Query supports only a string
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 5.5 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Query | Keywords: | good-first-bug has-patch |
| Focuses: | docs | Cc: |
Description
In the DocBlock of WP_Query::parse_query() the type of $fields is currently documented as string|array but it's only a string as it only accepts 'ids' and 'id=>parent'. Looks like it has been copied from WP_User_Query.
Related: #19866.
Attachments (3)
Change History (11)
#3
@
7 years ago
- Keywords needs-refresh added
- Owner set to johannadevos
- Status changed from new to assigned
Thanks for the patch!
Reading the updated comment, it's not 100% clear to me that fields can be set to three and only three options:
'id'which makes the query return only e.g. post IDs.'id=>parent'which makes the query return only e.g. post IDs and their parent IDs.- Anything else, e.g.
'', which makes the query return all fields.
Could we try to have the comment enumerate these options? Here's my suggestion:
Which fields to select. Accepts 'ids', which selects just the post ID; 'id=>parent', which selects just the post ID and the post_parent ID; and '', which returns all fields.
#4
@
6 years ago
- Keywords needs-refresh removed
- Milestone changed from Future Release to 5.5
44305.3.diff uses the same format as used in WP_Term_Query.
This ticket was mentioned in Slack in #core by david.baumwald. View the logs.
6 years ago
Note: See
TracTickets for help on using
tickets.
I have created a second patch which improves the first patch (
44305.diff) in two ways:$fields(and the description after it) on line 634 were one space character to the left of all of the other code.$fieldsdescription.