Created
June 4, 2012 09:51
-
-
Save antoniofrignani/2867542 to your computer and use it in GitHub Desktop.
[WP] - Rewrite the search results slug to /search/term
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
// http://wpsnipp.com/index.php/functions-php/rewrite-the-search-results-slug-search-term/ | |
function search_url_rewrite_rule() { | |
if ( is_search() && !empty($_GET['s'])) { | |
wp_redirect(home_url("/search/") . urlencode(get_query_var('s'))); | |
exit(); | |
} | |
} | |
add_action('template_redirect', 'search_url_rewrite_rule'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment