[wp-trac] [WordPress Trac] #15063: Add a "context" property to WP_Query as a 2nd param to its constructor

WordPress Trac wp-trac at lists.automattic.com
Mon Oct 11 20:29:58 UTC 2010


#15063: Add a "context" property to  WP_Query as a 2nd param to its constructor
--------------------------+-------------------------------------------------
 Reporter:  mikeschinkel  |        Owner:                 
     Type:  enhancement   |       Status:  closed         
 Priority:  normal        |    Milestone:  Awaiting Review
Component:  Post Types    |      Version:                 
 Severity:  normal        |   Resolution:  wontfix        
 Keywords:                |  
--------------------------+-------------------------------------------------

Comment(by prettyboymp):

 I have a couple of reservations about adding a 'context' as a 2nd
 parameter.  First, it can be added as a query_var passed into WP_Query
 that is just as easy to access as if it were a direct property of
 WP_Query.  The second is that 'context' describes the theme context, but
 not really the data that needs to be returned.  A query_var that related
 more to the filter would be better here.


 {{{
 $query = new WP_Query('post_type=movie&my_list=1');
 }}}

 {{{
 function posts_where($where,$query) {
         if ($query->get('my_list')) {
                 $where .= //my new restraint
         }
         return $where;
 }
 }}}

 This not only better describes the filter, but allows you to potentially
 pass in several query modifiers instead of just one that context would
 represent.

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


More information about the wp-trac mailing list