0

I've added a custom form to one of my page templates. It submits to itself $_SERVER['REQUEST_URI'] in hopes I can grab the $_GET values and modify my query using pre_get_posts, but instead it goes to 404.

So to clarify, I don't want to use search.php, I want it to post back to my page template and modify my query to show the "filterd" results instead of 404ing.

I've tried using pre_get_posts to test if it's 404 or search, but I also don't want to stop anything else from 404ing.

So how can I use a query on the same page / url / page template without needing to reply on search.php or having my query cause a 404?

So with the custom search form in place the url is currently http://mydomain.com/page-slug/?year=1111 - and I want to modify the query on the specific page depending on the $_GET value.

1 Answer 1

1

Don't use a query variable that is used by the WordPress Core. That is, none of these.

You are using year. WordPress will latch onto that and process the request according its internal systems. Try something more distinct like hmg_year.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.