I want to change the search URL from example.com/search/keyword
to example.com/result
or topic/keyword
.
Leave a Reply
You must be logged in to post a comment.
I want to change the search URL from example.com/search/keyword
to example.com/result
or topic/keyword
.
You must be logged in to post a comment.
You can change the
/search/
part to something else, like/topic/
, but it will be harder to remove it completely, since that will conflict with WordPress Pages (is/banana/
a Page with the title “Banana” or is it the result page for the search term “Banana”?).To change the part, hook into the
init
action and change the$wp_rewrite->search_base
variable:You will need to place this snippet of code in your theme’s
function.php
file, or in a new file that you create and that you place in the/wp-content/plugins/
directory. After you did this, visit the Permalinks setting page to flush the rewrite rules.However, by default when you submit a search you will end up on a URL like
?s=Banana
. There are plugins that change this (Ramukar linked to one, but it has the/search/
part hardcoded and has other issues), and Hudson Atwell linked to a simple approach (even too complicated now: you don’t need to add the rewrite rule to Apache, as WordPress already contained them since version 1.5).Just install this plugin, Search Permalink.that’s it.you got answer.:)