Redirect WordPress Searches

Wordpress WordPress comes with it's own in-built search functionality which can search the title and content of all your posts on your WordPress site.

To perform a search on your WordPress site all you have to do is create a search form which posts a GET parameter s to the home page of your WordPress site.


WordPress will then search for all posts which have the word WordPress in them. But the URL of the search page is just domain/?s=[search query]. This is a messy URL, which you can change to be /search/wordpress, by using the following code snippet.

Add the following to your functions.php file.

function redirect_search() {
	if (is_search() && !empty($_GET['s'])) {
add_action('template_redirect', 'redirect_search' );
Back to top

Learn how to code with Treehouse

  • Learn projects with access to 1000+ videos
  • Practice live with our Code Challenge Engine
  • Get help in our members-only forums

Start with a 7 day free trial