I recently had a similar problem and it had something to do with the query’s posts_per_page
parameter. Try setting it explicitly, like so:
function custom_search_filter($query) {
if ( !is_admin() && $query->is_main_query() ) {
if ($query->is_search) {
$query->set('posts_per_page', 10 ); // Try setting it to the number you've set in the WordPress admin (Settings > Reading).
$query->set('post_type', array('post','product'));
}
}
}
add_action('pre_get_posts','custom_search_filter');
Hope this helps!