Support

Account

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.