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 keep myself busy with the functionality, management, maintenance and performance of self hosted WordPress. I like to share this knowledge. All in my spare time!

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu