Created
October 6, 2012 05:48
-
-
Save dhigginbotham/3844128 to your computer and use it in GitHub Desktop.
Query Multiple Post Types with same Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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