Skip to content

Instantly share code, notes, and snippets.

@robertcedwards
Created May 15, 2013 23:52
Show Gist options
  • Save robertcedwards/5588388 to your computer and use it in GitHub Desktop.
Save robertcedwards/5588388 to your computer and use it in GitHub Desktop.
Custom Post Types in the Main Query
// 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