[wp-trac] [WordPress Trac] #21660: 'p' arg should work with custom post types

WordPress Trac wp-trac at lists.automattic.com
Wed Aug 22 15:27:50 UTC 2012


#21660: 'p' arg should work with custom post types
--------------------------+-----------------------------
 Reporter:  batmoo        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Query         |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Doing a query like following, where 42 is a custom post_type, will fail:

 {{{
 $query = new WP_Query( array( 'p' => 42 ) );
 }}}

 The resulting query looks like:

 {{{
 SELECT wp_posts.* FROM wp_posts  WHERE 1=1  AND wp_posts.ID = 42 AND
 wp_posts.post_type = 'post'  ORDER BY wp_posts.post_date DESC
 }}}

 This is because WP_Query forces the {{{post_type}}} arg to 'post' when
 it's not set. We should not force it when the {{{p}}} arg is set.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21660>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list