Created
August 13, 2014 13:29
-
-
Save keithdevon/967d58f718825c90ce52 to your computer and use it in GitHub Desktop.
Custom post types in home and blog pages
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
// Add custom post types to the home and blog pages | |
// change 'cpt1' and 'cpt2' to your post type names | |
add_filter( 'pre_get_posts', 'my_get_posts' ); | |
function my_get_posts( $query ) { | |
if ( is_home() && $query->is_main_query() ) | |
$query->set( 'post_type', array( 'post', 'cpt1', 'cpt2' ) ); | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment