Changing search URL
-
Hello!
I’d like to change the default WordPress search URL. I was searching for a solution, found the code below on almost every site I visited:
/** * Change search page slug. */ 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' );
The code by itself works I guess, but the search now looks completely different than before, the whole search page is changed – instead of products being positioned normally, they are positioned below eachother. You can see this here.
Let’s say for example that I’m searching for “Bazen”. The default search looks like /?s=bazen&post_type=product. What I’d like is just a simple /iskanje/bazen
If I change /search/ in the code that I added to this request, I get the proper URL, but the page just shows 404 error.
How can I edit this?
Kind regards
The page I need help with: [log in to see the link]
- The topic ‘Changing search URL’ is closed to new replies.