[wp-trac] [WordPress Trac] #19866: Allow specifications of any wp_posts field(s) in WP_Query
WordPress Trac
wp-trac at lists.automattic.com
Fri Jan 20 19:58:44 UTC 2012
#19866: Allow specifications of any wp_posts field(s) in WP_Query
-------------------------+-----------------------------
Reporter: bigdawggi | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Keywords:
-------------------------+-----------------------------
Hi guys, I'm considering writing a patch to be able to pull specific
fields from a WP_Query but wanted to see if there was already something in
the works on another ticket. I searched trac and hackers list (via its
Google Group) and surprisingly didn't see anything.
Here's the current implementation which limits people to only querying for
certain fields: wp-includes/query.php:2033
{{{
switch ( $q['fields'] ) {
case 'ids':
$fields = "$wpdb->posts.ID";
break;
case 'id=>parent':
$fields = "$wpdb->posts.ID,
$wpdb->posts.post_parent";
break;
default:
$fields = "$wpdb->posts.*";
}
}}}
Stems from a situation where we needed all posts of a certain type --
potentially thousands -- but really only required post_title and ID
fields, so didn't want all that memory overhead.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19866>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list