How to get WordPress to ignore the search parameter in the frontend?
What you can try, is hooking in earlier, to remove the public search query variable, like (untested):
add_filter( 'request', function( $qv ) {
if ( ! is_admin() && isset ( $qv['s'] ) ) {
unset( $qv['s'] );
}
return $qv;
} );
We are here hooking into WP::parse_request()
where query variables are first registered into WordPress from GET/POST request parameters.
I can also unset the query string variable s using the parse_query
hook. This then loads search results as if the search was for an empty
string.
Note that query variables are restored soon after the pre_get_posts
hook runs, in case they were unset:
// Fill again in case 'pre_get_posts' unset some vars.
$q = $this->fill_query_vars( $q );
https://github.com/WordPress/wordpress-develop/blob/6.5/src/wp-includes/class-wp-query.php#L1887