4
Php

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
Php

PHP – 8.0 Match Expression

In PHP 8.0 there is a new feature or I should say a new language construct (keyword) going to be introduced,  which has been implemented depending […]