[wp-trac] [WordPress Trac] #40082: Pretty links for users when searching
WordPress Trac
noreply at wordpress.org
Thu Mar 9 17:22:30 UTC 2017
#40082: Pretty links for users when searching
--------------------------+------------------------------
Reporter: henry.wright | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 4.7.3
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by lukecavanagh):
@henry.wright
You can already do this using the '''wp_redirect''' function.
https://developer.wordpress.org/reference/functions/wp_redirect/
Add this to the site functions.php or as a code snippet.
{{{#!php
function wp_change_search_url_rewrite() {
if ( is_search() && ! empty( $_GET['s'] ) ) {
wp_redirect( home_url( "/search/" ) . urlencode(
get_query_var( 's' ) ) );
exit();
}
}
add_action( 'template_redirect', 'wp_change_search_url_rewrite' );
}}}
Example
http://example.com/search/hello+world
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40082#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list