[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
Fri Oct 8 22:29:41 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 hakre):

 In PHP you can just add public members to a class att runtime.

 {{{
 $query = new WP_Query();
 $query->context = 'named';
 }}}

 now in a hook, you can check for the query object's context:

 {{{
 action_callback( $query ) {
   if ( empty($query->context) || 'named' !== $query->context )
     return;
   // your context specific code here
 }
 }}}

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


More information about the wp-trac mailing list