comment 0

Change plus into minus on search permalink

change the plus into minus on search permalink

How to change the plus into minus on search permalin? usually we found our search permalink was site.com/search/what+the+hell and here its the way to change into site.com/search/what-the-hell .

1. Login to your cpanel, site.com:2082

2. Open the file manager and goto themes directory, wp-content/themes/your-themes

3. Open search.php on your themes

4. Copy and paste this code on the first line before get header function , <?php get_header(); ?>

<?php
if($_GET['s']!=''){
$ganti = array('+',' '); //tanda plus dan spasi
$urlredirect = get_settings('home') . '/search/' . str_replace($ganti, '-' ,$_GET['s']). ''; //tanda plus dan spasi jadi minus
header("HTTP/1.1 301 Moved Permanently");
header( "Location: $urlredirect" );
}
?>

5. Save your search.php , open the dashboar (wp-admin) goto permalink settings, save the settings and preview your site, thats work on my site

Happy Coding ^ ^

regads

r3m1ck

Leave a Reply

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