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!

Leave a Reply

Notify of