Redirect to the one post found in search results

Redirect to the one post found in search results

When you search on a WordPress website, you always get the results page in return. Even when the result is just one post or page.

With the code below you can skip the results page when the search result is just one post or page. You will be sent directly to that post or page. This saves your visitors one mouse click!

Add this code to the functions.php of your theme and test the modified search.

Always backup your functions.php before you start changing it!

Ronald Heijnes

Since 2008 I have been busy with the functionality, management, maintenance and performance of self hosted WordPress. I like to share this knowledge!

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz
Close Menu