WordPress Display Custom Post Types on Homepage or Blog Page

In this quick tutorials you learn how to display custom post type content on the your homepage feed or blog page like regular posts, it is easily done using this snippet that you need to add to your functions.php file:


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', 'page', 'album', 'movie', 'quote', 'reviews', 'coupons' ) );

return $query;
}

That’s all, you need to add your own custom post type name, like the example above movie, reviews and so on even pages.