Hello everyone
I would like to create a cooking recipe form that sends the information after submission in a recipe post type
So I have a form so that the user can enter their data
Who is next
<?php /*Template Name: User Submit*/; ?>
<?php acf_form_head(); ?>
<?php get_header(); ?>
<div id="container" >
<div class="row">
<div class="col-sm-12">
<?php /* The loop */ ?>
<?php while (have_posts()):
the_post(); ?>
<!-- a supprimer si on enlève l'éditeur par défaut -->
<!------------>
<p> <?php the_field('Ingredients'); ?></p>
<p> <?php the_field('Cuisson'); ?></p>
<p> <?php the_field('Temps'); ?></p>
<p> <?php the_field('Preparation'); ?></p>
<p> <?php the_field('Difficulté'); ?></p>
<?php $options = array(
'post_id' => 'new',
'field_groups' => array(
4
) ,
'post_title' => true,
'post_type' => 'recette',
'post_status' => 'draft',
//'updated_message' => 'Merci pour votre participation!Votre recette sera publiée prochainement',
'updated_message' => __("Recette publiée", 'acf') ,
'submit_value' => 'Postez votre recette'
);
acf_form($options); ?>
<?php
endwhile; ?>
</div>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
I created a recipe CPT
And a single.php file to display the result
the problem is that the articles created will be added in article and not in recipe
You need to set the ‘new_post’ argument for acf_form(), not ‘post_type’ and ‘post_status’. The value of this argument is an array of values.
....
'new_post' => array(
'post_type' => 'recette',
'post_statues' => 'draft'
),
......
thank you for the answer
but this is at the level of the function file
No, I was talking about your options for calling acf_form(). Yours are wrong.
$options = array(
'post_id' => 'new',
'field_groups' => array(
4
),
'post_title' => true,
'new_post' => array(
'post_type' => 'recette',
'post_status' => 'draft',
),
'updated_message' => __("Recette publiée", 'acf'),
'submit_value' => 'Postez votre recette'
);
acf_form($options);
You must be logged in to reply to this topic.
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.