Hi I have kind of an unusual task that I'm not sure exactly how to approach. I would like to change the query string shown in the url bar to use “?q=” instead of “?s=”
I am using Elementor as well as Relevanssi. I originally posted in Relevanssi, but from what I understand, now I believe I have to alter the query before it's sent to Relevanssi, so this is the more appropriate place to post.
I’ve looked into altering the form as well as using some php to intercept and alter the query before sending it to Relevanssi. I'm okay creating a custom search submission form or adding some logic to functions.php.
I have tried this (thanks @msaari), which allows the query to succeed if I manually change the s to q in the url bar, but the search still defaults to s when using the search form.
add_action( 'parse_query', function( $query ) {
if ( isset( $_REQUEST['q'] ) && ! empty( $_REQUEST['q'] ) ) {
$query->set( 's', $_REQUEST['q'] );
$query->is_search = true;
}
} );
I am not very experienced in the realm of search so any advice or resources would be very appreciated.
Thanks!