[wp-hackers] how to query all posts from post type and some posts from another post type?

Steve Taylor steve at sltaylor.co.uk
Mon May 7 15:16:24 UTC 2012


> You can use an array for the post_type parameter in WP_Query, ie:
>
>    $query = new WP_Query( array( 'post_type' => array( 'post', 'fdp-post' )
> ) );

The issue then is, how to do a tax_query that for only restricting one
post type by category. Probably not possible

You might attack things differently by doing the above type of query
and then manually filtering stuff in PHP according to taxonomy, but I
wonder if this might end up with more DB hits than doing two
WP_Queries, one for each post type, and then concatenating and sorting
in PHP.


More information about the wp-hackers mailing list