Custom WordPress search and query url

I try to create a custom search page in a WordPress website. I read a few tutorials on Google and I have almost finished with it.

My theme uses the index.php page for the search results. So, I duplicated it, rename it to searchpage.php, made it a template and created a page with this template in WordPress admin.

Read More

Then, I changed the action on the Search form to use the new page of /search.

If I manually try the /search/test/ it works. If I use the widget it redirect to /search/?s=test and returns a 404 page.

Is there any way to make both works or prevent the widget to use the second?

Also, the /search/test still uses the index.php layout instead of the searchpage.php

Related posts

1 comment

  1. In order to overwrite index.php as the default search results page you’ll need to name your file search.php

Comments are closed.