0

I have a WordPress page /floorplans/ that is submitting a form with the attributes method="post" and action="/contact/" to the '/contact/' page. Before I do anything else on the contact page, I am var_dumping the $post variable to make sure it is what I am expecting, but instead of getting the contact page in the $post variable, I am getting the instance of the custom post type "floorplan" that corresponds to the variable $_POST['floorplan'] that was submitted in the post request to the contact page. What is going on?

<!-- /floorplans/ page -->
<form method="post" action="/contact/">
    <input type="text" value="example" />
    <button>Submit</button>
</form>

<!-- /contact/ page -->
<?php
    var_dump($post);
    exit;
?>
<!-- Here I expect to see a var dump of the contact page, but instead I get a var dump of the custom post type instance that corresponds to the value that I entered in $_POST['floorplan'], as if this value were a post_name. -->

1 Answer 1

0

While I was typing up this question, I left it for a while, found out the problem, and decided to post the answer just in case it helped anyone else. Apparently, in WordPress's infinite wisdom, it decided to make this argument in its register_post_types function:

'publicly_queryable'

When this is set to true, it causes this weird phenomenon. When it is set to false, it fixes this issue.

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.