Support

Account

Home Forums Front-end Issues No fields on frontend using acf_form() for new_post

Solved

No fields on frontend using acf_form() for new_post

  • Hello!

    I am using this as a guide:

    https://www.advancedcustomfields.com/resources/using-acf_form-to-create-a-new-post/

    But no fields will show up.

    The submit button appears on the page, but that’s it.

    If I set ‘post_id’ => ‘new_post’; is when nothing shows up. If I set the form to a specific post_id, then the fields for that post will show up, except for the title field, despite ‘post_title’ => true.

    I have acf_form_head() at the very top of the page template, above get_header().

    I have tried with only ACF plugin activated (all other deactivated), and using the 2016 WP default theme. Still the same result, only a submit button.

    <?php acf_form(array(
    		'post_id'		=> 'new_post',
    		'new_post'		=> array(
    			'post_type'		=> 'real-wedding',
    			'post_status'		=> 'pending'
    		),
    		'post_title' => true,
    		'submit_value'		=> 'Submit'
    )); ?>

    What could I be doing wrong?

  • In what template file are you including the acf_form() function?
    What post type are you trying to create?
    If you are trying to create a new “Post” then the function needs to be in the single.php file, or in one of the template parts used by this template. If you’re doing this in some other template then you’re going to need to supply the field groups that need to be included as part of the arguments to acf_form() https://www.advancedcustomfields.com/resources/acf_form/

  • Ah, I didn’t know I had to declare the field group. The example didn’t include it, so I wasn’t sure. Thanks!

    This is in a page.php template, but is for creating a post within a CPT ‘real-wedding’.

    So, now I have the fields showing up by adding the field_group:

    <?php acf_form(array(
    		'post_id'		=> 'new_post',
    		'new_post'		=> array(
    			'post_type'		=> 'real-wedding',
    			'post_status'		=> 'pending'
    		),
    		'post_title' => true,
    		'field_groups' => array('13612'),
    		'submit_value'		=> 'Submit'
    )); ?>

    The post_title field doesn’t show still though. Is there something else that needs to be done for that? Does it not show because the form isn’t embedded in the single-real-wedding.php file?

  • I tested you code and the post title field shows up for me.

    What version of ACF are you using?

  • Using Version 4.4.7

    I read here that ACF Pro has to be used just to get the title field:

    https://support.advancedcustomfields.com/forums/topic/acf_form-not-displaying-post-title-field-in-the-front-end/

    Is this true? I have bought other extension packs, but I have to get pro to make this work?

    Is there a workaround that I could do, like setting a default title, or have the title be dynamically generated from some of the custom fields that are filled out? If not, I’ll just get Pro. Thanks for your help on this.

  • You could add a field to use as the title and then use an acf/save_post filter to copy the value of the title into the post title. There’s an example of this here https://support.advancedcustomfields.com/forums/topic/createupdate-post-title-from-acf-fields/

    You might want to log into your account and see if you can download a copy of ACF5 Pro. At one time people that purchased one of the premium add ons were eligible for a free upgrade to Pro, but I don’t know if this is still the case, it may have been a limited time thing. But if you log into your account and you are then it will be listed in the files you can download.

  • Awesome! Thanks for the suggestion to look in my account. There was a free upgrade to Pro sitting there and waiting for me.

    Used this to upgrade to Pro properly

    https://www.advancedcustomfields.com/resources/upgrading-v4-v5/

    All went well, and the title field is showing, and the custom post was created via the form.

    YAY! Thanks again.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.