Created
February 7, 2014 10:00
-
-
Save craigpearson/8860034 to your computer and use it in GitHub Desktop.
Roots nice search redirect - fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function roots_nice_search_redirect() { | |
$valued = $_GET["post_type"]; | |
if(!empty($valued)) { $valued = "?post_type=".$valued; }; | |
if (is_search() && strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === false && strpos($_SERVER['REQUEST_URI'], '/search/') === false) { | |
wp_redirect(home_url('/search/'.str_replace(array(' ','%20'),array('+', '+'),urlencode(get_query_var('s'))).$valued), 301); | |
exit(); | |
} | |
} | |
add_action('template_redirect', 'roots_nice_search_redirect'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment