Google Ads

Change WordPress search Url


How to change ?s=search

 

From

domain.com/?s=oppo

To

domain.com/search/oppo

 

1. Go to your hosting panel and go to domain.com/wp_content/themes/functions.php

2. Open Function.php from your activated Theme and Add following code bottom of all codes.

 

 
 
  1. function wpb_change_search_url() {
  2. if ( is_search() && ! empty( $_GET['s'] ) ) {
  3. wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) );
  4. exit();
  5. }
  6. }
  7. add_action( 'template_redirect', 'wpb_change_search_url' );

 

Save and Enjoy.

 

Now, go to your site and search something to get result.

 

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

"