comment 0

Change search permalink from plus into minus (2)

change search permalink from plus into minus

Ok last time I was give a tutorial about how to change search permalink plus into minus, now I will give a nice plugin to change your search query and change the plus into minus, here is the plugin

<?php
 /*
Plugin Name: plus to minus
Version: 0.1
Description: Redirects ?s=query searches to /search/query, and converts %20 to -
Author: r3m1ck rahmani
Author URI: http://r3m1ck.us/
*/
 
function plus_to_minus() {
	if ( is_search() &amp;&amp; strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false &amp;&amp; strpos($_SERVER['REQUEST_URI'], '/search/') === false ) {
		wp_redirect(get_bloginfo('home') . '/search/' . str_replace(' ', '-', str_replace('%20', '+', get_query_var('s'))));
		exit();
	}
}
 
add_action('template_redirect', 'plus_to_minus');
 
?>

save into plus-minus.php and then upload it to your plugins directory on cpanel or zip it and install on plugins in dashboard wordpress admin.

You can see the code here

Happy coding happy bloging ^ ^

Leave a Reply

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