Selecting multiple post types in a single query

Sometimes you need to display a variety of different posts. E.g. if your website has besides the standard blog post also a number of custom post types and you want to display a list of the latest added content.

This is no problem for WordPress. Simply specify the various posts types in WP_Query or query_posts using an array:

$query = new WP_Query(
      'post_type' => array('post', 'book', 'gallery', 'promo', 'casestudy'),

That’s all there’s to it.

Bon App├ętit!

Tagged with: