Created
May 15, 2013 23:52
-
-
Save robertcedwards/5588388 to your computer and use it in GitHub Desktop.
Custom Post Types in the Main Query
This file contains hidden or 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
// Show posts of 'post', 'page' and 'movie' post types on home page | |
add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); | |
function add_my_post_types_to_query( $query ) { | |
if ( is_home() && $query->is_main_query() ) | |
$query->set( 'post_type', array( 'post', 'page', 'movie' ) ); | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment