Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Change the WordPress search query parameter from 's' to something else
<?php
add_filter('init', function(){
global $wp;
$wp->add_query_var( 'search_query' );
$wp->remove_query_var( 's' );
} );
add_filter( 'request', function( $request ){
if ( isset( $_REQUEST['search_query'] ) ){
$request['s'] = $_REQUEST['search_query'];
}
return $request;
} );
@gianghl1983

This comment has been minimized.

Copy link

@gianghl1983 gianghl1983 commented Oct 1, 2020

Hi,

I am trying to do without SearchWP (same purpose to change 's' to something else with this code snippet but it doesn't work)

Could you please help me!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.