Home › Forums › General Issues › differentiate between post types on acf/pre_save_post › Reply To: differentiate between post types on acf/pre_save_post
Hi Elliot,
I have set 'html_after_fields' => '<input type="hidden" name="post_type" value="products">'
in the form to the options array. In the functions.php, I have $post_type = $_POST['post_type'];
to reuse the same form for posting different post types.
But this is breaking and after submission, it redirects to 404. I think this is because the hidden field is nested inside <div id="poststuff">
.
Is there any way I can move it outside the poststuff div?
I tried looking at the source in api.php but did not find any way to directly set the post type into the $options array. I think it would be great to have an option to set post_type in the options array and if it is not set, then default it to “post”.
Thanks.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.