4

Pretty Url in WordPress Search Result

In WordPress, the search url is not pretty, I mean it’s not search engine friendly (uses query string), it looks something like http://example.com?s=foo and it’s doesn’t look very professional. So, if you want to change the url to something like http://example.com/search/foo then it’s possible and very easy, just 2 steps.

Step 1 :

Create a file called search.php which contains following code

Now put the file in the root of your WordPress install.

Step 2 :

Alter the action attribute of the search form to <?php bloginfo('url'); ?>/search.php, i.e.

That’s it. Now the search url will look really pretty something like https://heera.it/search/foo, which looks professional and search engine friendly too, isn’t it very simple ? I think it is.

Latest Blog

0

New Union Type in PHP – 8

A new RFC has been finished voting and accepted for PHP – 8. That is “Union Types”, which is an extension of PHP’s type system. […]