[wp-trac] [WordPress Trac] #16844: WP_Query::get_posts() pollutes the 'orderby' query var

WordPress Trac wp-trac at lists.automattic.com
Sun Mar 13 07:36:06 UTC 2011


#16844: WP_Query::get_posts() pollutes the 'orderby' query var
--------------------------+------------------------------
 Reporter:  scribu        |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Query         |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------------------
Description changed by scribu:

Old description:

> After running through get_posts(), the 'orderby' query var no longer
> contains the original value, but the final SQL code.
>
> Thus, instead of:
>
> {{{
> if ( 'some_value' == $wp_query->get( 'orderby' ) )
> }}}
>
> you have to do:
>
> {{{
> if ( isset( $wp_query->query['orderby'] ) && 'qa_score' ==
> $wp_query->query['orderby'] )
> }}}

New description:

 After running through get_posts(), the 'orderby' query var no longer
 contains the original value, but the final SQL code.

 Thus, instead of:

 {{{
 if ( 'some_value' == $wp_query->get( 'orderby' ) )
 }}}

 you have to do:

 {{{
 if ( isset( $wp_query->query['orderby'] ) && 'some_value' ==
 $wp_query->query['orderby'] )
 }}}

--

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


More information about the wp-trac mailing list