[wp-trac] [WordPress Trac] #14777: Adding "fields" to arguments array for get_posts()/query_posts()/WP_Query()

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 4 20:14:37 UTC 2010


#14777: Adding "fields" to arguments array for get_posts()/query_posts()/WP_Query()
--------------------------+-------------------------------------------------
 Reporter:  mikeschinkel  |       Owner:             
     Type:  enhancement   |      Status:  new        
 Priority:  normal        |   Milestone:  3.1        
Component:  Query         |     Version:             
 Severity:  normal        |    Keywords:  needs-patch
--------------------------+-------------------------------------------------

Comment(by mikeschinkel):

 Replying to [comment:2 scribu]:
 > I think this is a good idea, similar to how we have a 'fields' argument
 in get_terms().

 Replying to [comment:3 filosofo]:
 > I agree that this would be helpful.  I am continually iterating through
 an array of post objects just to populate another array with a single
 object property.  This would eliminate that extra runtime work and reduce
 db work.

 Awesome, thanks.

 '''Note:'' `get_terms()` delineates a named set of fields: `all`, `ids`,
 `id=>parent`, `names` and `count`.  Would we do the same or just let it be
 free-form?

 I like the consistency of the former but the flexibility of the latter.
 There have been times when I needed fields from `get_terms()` that just
 were not available via `$args` and having it freeform would solve that
 issue. Also, if we have to delineate them we'll have to go into decision
 mode to see what will be our options.

 All in all I think I vote for simple field list.

 Or we could reserve `fields` for a name sets and instead add a
 `field_list` in 3.1 now which would be freeform. Later we could add
 `fields` if needed and it would override `field_list` (or vice-versa?)
 That would give both flexibility and consistency.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14777#comment:7>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list