Advertisement
niammuddin

redirect permalink search form wordpress

Jul 27th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.47 KB | None | 0 0
  1. <?php
  2. <?php
  3. if(is_search()):
  4.         $m3 = strtolower( $_GET['s'] );
  5.         $m3clean = preg_replace("/[^ 0-9a-zA-Z]/", " ", $m3);
  6.         while (strstr($m3clean, "  ")) {
  7.                 $m3clean = str_replace("  ", " ", $m3clean);
  8.         }
  9.         $m3clean = urlencode($m3clean);
  10.         $m3clean = str_replace("+", "-", $m3clean);
  11.         if ($m3 != '') {
  12.                 header('Location: '.home_url($basepermalink).'/'.$m3clean.''.$endpermalink.'');
  13.         }
  14. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement