The name
attribute of the input element becomes the query parameter in the URL when the form is submitted. So for an input with the name s
the URL will look like:
http://example.com/?s=my+search+query
WordPress is built so that the s
parameter indicates a search, so it then queries based on that value and loads the search.php template.
There isn’t a way to change the name of the query parameter used for search per se, but you could use an early hook to manually set the value of $_GET['s']
to the value of your own parameter name.
For example, if you wanted to use q
as the input name:
function wpse_324429_search_parameter() {
if ( isset( $_GET['q'] ) ) {
$_GET['s'] = $_GET['q'];
}
}
add_action( 'init', 'wpse_324429_search_parameter' );
Manually setting a value in $_GET
feels wrong to me, but I can’t see why it wouldn’t work.