Search uses index.php instead of search.php on renaming search field from “s”

I am building a custom search form which has multiple search boxes and I rename them to “searchbox1” from “s”. Now WP does not use search.php; instead the code is execured from index.php. How can I make it to use search.php?

2 Answers
2

Well, the s is not just a name/ID, it’s a query var, as the form’s fields are injected by means of GET or POST to the URL which is then checked for the s query var.

If the s query var is defined, the search.php (if present in your theme) will then be called automatically.

It’s okay if you have multiple searchboxes having fields that share the same name. Each searchbox has its own form anyway.

In short: rename the search’s input field back to s (or tweak the redirects/rewrites etc. which is nonsense, in my opinion).

Leave a Comment