Type Here to Get Search Results !
Hi ,

We always try to serve you better. Please enter the institute name, you belong to.

Hello ,

Your daily download limit has been exhausted. Share it with your friends to download more.

Change search query parameter from 's' to 'q' or something else in wordpress

 WordPress is the most customizable and easy platform for blogging. WordPress may uses many sensible defaults one of which is how native searches are triggered.

A query parameter of s triggers WordPress search, resulting in a URL that looks something like this, by default:


If you’d like to instead use something that more clearly describes what’s happening at this URL, you may want to use search_query as your query parameter instead of s. You can do that by adding something like this to your theme’s functions.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;
} );
View Original Code From GitHub 

Note: This may cause problem when theme updates to default. It may remove all your added codes.

Once that’s in place, your search URLs will now look like this:
Which may suit your needs a bit better.

Post a Comment

* Please Don't Spam Here. All the Comments are Reviewed by Admin.