Posts Tagged ‘URL’

 
 

How To Change Search URL on WordPress

Posted 19 Sep 2011 — by WPGPL Team
Category WordPress Tricks

We already know that WordPress Search URL is http://wpgpl.com/search/keyword right? Now we got nicely tips and we will show you how to change this search URL permalink. This tips coming from Andrew Keith. You need to paste this code on functions.php to make it works.

Open your functions.php on your theme and add this code

function custom_search_url( $search_rewrite ) {
if( !is_array( $search_rewrite ) ) { return $search_rewrite; }

$new_array = array();
foreach( $search_rewrite as $pattern => $s_query_string ) {
$new_array[ str_replace( 'search/', 'new-search-url/', $pattern ) ] = $s_query_string;
}
$search_rewrite = $new_array;
unset( $new_array );
return $search_rewrite;
}
add_filter("search_rewrite_rules", "custom_search_url");

Please notes this code didn’t redirect any /?s=Search but this code will redirect any /search/ into something else domain. We hope this tutorial to change search URL on WordPress worked on you