Custom Post Types (CPTs) are not included in WordPress search results by default. The following snippet lets you choose which custom post types to add to WordPress search results. Add this code to your theme’s functions.php file and change the post type names as needed:
function custom_post_type_search( $query ) {
if ($query->is_search) {
$query->set('post_type', array( 'post', 'myCustomPostType1', 'myCustomPostType2', 'myCustomPostType3'));
}
return $query;
}
add_filter( 'pre_get_posts', 'custom_post_type_search' );If you want more advanced search options, take a look at the post “Improving search with Relevanssi“.