Enabling a Custom Post Type in Search Results
Whether to include a custom post type in search or not is determined when registering the post type; in the arguments of the register_post_type() function: the public=true argument adds the custom post type to the search results.
If the custom post type is not included in search, but you need it to participate in search, then use the following code, analogous to the previous one:
add_action( 'pre_get_posts', 'get_posts_search_filter' );
function get_posts_search_filter( $query ){
if ( ! is_admin() && $query->is_main_query() && $query->is_search ) {
$query->set( 'post_type', [ 'post', 'movie' ] );
}
}—
Note embeded into: pre_get_posts