Add Custom Post Type to Main Query Loop

If you want to add a custom post type (CPT) to the main query loop, use the snippet below:

add_action( 'pre_get_posts', 'wpkb_add_my_post_types_to_query' );

function wpkb_add_my_post_types_to_query( $query ) {
    if ( is_home() && $query->is_main_query() ) {
        $query->set( 'post_type', array( 'post', 'page', 'recipe' ) );
    }

    return $query;
}

recipe is the desired CPT and has to be changed.