Skip to content

Instantly share code, notes, and snippets.

@dhigginbotham
Created October 6, 2012 05:48
Show Gist options
  • Save dhigginbotham/3844128 to your computer and use it in GitHub Desktop.
Save dhigginbotham/3844128 to your computer and use it in GitHub Desktop.
Query Multiple Post Types with same Query
//try to include two post types in main query
function query_multiple_posts_types( $query ) {
if ( is_home() ) {
//Display 20 posts
$query->query_vars['posts_per_page'] = 20;
//Display multiple post types
$query->query_vars['post_type'] = array('post', 'portfolio');
return;
}
}
add_action('pre_get_posts', 'query_multiple_posts_types', 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment