Changing search URL to something other than “search”

Question

Why is it that when I attempt to change the URL for searches, it breaks if set to anything other than search?

function bfm_pretty_search () {

    if (is_search() && !empty($_GET['s'])) {
        wp_redirect(home_url('/search/').urlencode(get_query_var('s')));
        exit();
    }

}
add_action('template_redirect', 'bfm_pretty_search');

So, instead of the url looking like mydomain.com/search/query, I’d like it to be: mydomain.com/results/query, but it doesn’t work with anything other than “search”… why?

0
, John Robinson 5 years 2017-01-18T00:13:08-05:00 0 Answers 87 views 0

Leave an answer

Browse
Browse