add_action( 'pre_get_posts', function( $query ) {
// Check that it is the query we want to change: front-end search query
if( $query->is_main_query() && ! is_admin() && $query->is_search() ) {
// Change the query parameters
$query->set( 'posts_per_page', 10 );
}
} );