Last active
October 7, 2021 14:01
-
-
Save itsHall/e50fc5ce9dcb8e6547448568507c8d0b to your computer and use it in GitHub Desktop.
Change Search Path | WP
This file contains 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
<?php | |
// Changes /s/ search path to /search/ | |
function wpb_change_search_url() { | |
if ( is_search() && ! empty( $_GET['s'] ) ) { | |
wp_redirect( home_url( "/search/" . urlencode( get_query_var( 's' ) ) ) ); | |
exit(); | |
} | |
} | |
add_action( 'template_redirect', 'wpb_change_search_url' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment