This snippet will make the WordPress search function only return items that are a single post type. (posts, pages, custom posts types)

Just add the code below to your themes functions.php

function SearchFilter($query) {
    if ($query->is_search) {
        $query->set('post_type', 'post');
    }
    return $query;
}
add_filter('pre_get_posts','SearchFilter');

Make sure to change ‘post’ to your required post type.