[wp-trac] [WordPress Trac] #31112: WP_Query fields=>ids parameter sometimes returns post objects instead of array of post IDs
WordPress Trac
noreply at wordpress.org
Fri Jan 23 20:42:00 UTC 2015
#31112: WP_Query fields=>ids parameter sometimes returns post objects instead of
array of post IDs
--------------------------+-----------------------------
Reporter: lisota | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I am trying to return an array of post IDs from a custom WP_Query. Simple
queries like this seem to work fine:
{{{
$args = array(
'post_type" => 'sponsor_post',
'fields' => 'ids'
);
$query = new WP_Query($args);
}}}
That successfully returns a list of post IDs for my custom post type
called "sponsor_post".
Now add a meta_query to the parameter like so:
{{{
$args = array(
'post_type' => 'sponsor_post',
'meta_query' => array(
array(
'key' => 'sponsor_post_type',
'value' => 'advertorial',
'compare' => '!='
),
),
'fields' => 'ids'
);
$query = new WP_Query($args);
}}}
Now the query returns an array of post objects, despite the fact that I've
set the return parameter to 'fields' => 'ids'
How can I get WP_Query to respect the settings of the return fields
parameter?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/31112>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list