Home › Forums › ACF PRO › Issue with Live edit and ACF pro › Reply To: Issue with Live edit and ACF pro
Hi @eckul,
Thanks for the post.
It would be a lot easier if you could make use of the acf_form() function and pass the flexible content field key to the ‘fields’ argument of the form.
You will only need to pass the acf_form_head() function at the top of your template to handle the processing of the form data and the acf_form() function within the posts loop.
To create a new post, the code would look like so:
<?php acf_form_head(); ?>
<?php get_header(); ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php acf_form(array(
'post_id' => 'new_post',
'fields' => array('field_key'),
'new_post' => array(
'post_type' => 'event',
'post_status' => 'publish'
),
'submit_value' => 'Create a new event'
)); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.