Change the WordPress search query parameter from 's' to something else
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} ); |
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!
You might try this instead https://www.wpbeginner.com/wp-tutorials/how-to-change-the-default-search-url-slug-in-wordpress/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!