0

I've created a custom theme and a page template page-search.php, because the original search will search under the homepage url.

The page works just fine without query string but when I add /?s=1 at the end of the URL I get a 404, why is that?

Thanks

6
  • 1
    Is it a 404 or is it "no posts found" or similar? Those are two separate things. If you use ?s=1 in the URL then WordPress interprets that as a search query, searches for posts containing "1", then tries to load search.php from the theme, or index.php if it doesn't exist. Aug 16, 2022 at 16:45
  • 1
    It's because you change the main query by adding s, so unless your custom search page also matches the search it will find nothing. A page and a page template aren't how you should customize the URL of your search
    – Tom J Nowell
    Aug 16, 2022 at 16:54
  • @TomJNowell How would you customize the search URL? I don't mind using search.php but it's sending me to the homepage
    – odedta
    Aug 16, 2022 at 17:23
  • @JacobPeattie It's a 404 not found
    – odedta
    Aug 16, 2022 at 17:23
  • @odedta did you implement your custom homepage in index.php? Are you aware of home.php and frontpage.php?
    – Tom J Nowell
    Aug 16, 2022 at 17:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.