Home › Forums › General Issues › differentiate between post types on acf/pre_save_post › Reply To: differentiate between post types on acf/pre_save_post
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
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”.
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!
© 2022 Advanced Custom Fields.