Jonathan – thanks for all your assistance and hope everything is ok.
Disregard this Post. I needed to check the save terms to post option for the taxonomy custom field
I did as you recommended and the taxonomy does now show the categories that can be selected but these are not put to the post once it is created. I mean the form creates the new posts but they still list as Uncategorized in the post info. The ACF taxonomy field is keeping the selection from the fronted form but I am looking to use the standard WP categories like under each post the theme lists the category associated with that post.
Thanks
Andy
Jonathan,
Any further suggestions on making this work?
Thanks.
Andy
I have a page that has basically just this form on it. It is link directly from a menu button. If there are better ways to do this than I am open to suggestions. The pages works well for creating the posts and copying my title field & content field to the standard WP post fields.
It could be that the _Post lines in the template are not actually working and it is the ones in the function.php that are actually doing the copying from the front-end form to the WP posts. I did initially have issues with these fields not populating & did some searching to find the code that is in my function.php section.
Andy
Function.php
function acf_review_before_save_post($post_id) {
if (empty($_POST['acf']))
return;
$_POST['acf']['_post_title'] = $_POST['acf']['field_558eb15c51fc7'];
$_POST['acf']['_post_content'] = $_POST['acf']['field_558eb19c51fc8'];
$_POST['acf']['_post_category'] = $_POST['acf']['field_55d73c0ee19e4'];
return $post_id;
}
add_action('acf/pre_save_post', 'acf_review_before_save_post', -1);
Template for page with form
<?php acf_form(array(
'post_id' => 'new_post',
'new_post' => array(
'post_type' => '',
'post_status'=> 'publish',
'post_title' => $_POST['acf']['field_558eb15c51fc7'], // Post Title ACF field key
'post_content' => $_POST['acf']['field_558eb19c51fc8'], // Post Content ACF field key
'post_category' => $_POST['acf']['field_55d73c0ee19e4'], // Post Category ACF field key
),
'field_groups' => array(317), // Create post field group ID(s)
'form' => true,
//'return' => '%post_url%', // Redirect to new post url
'html_before_fields' => '',
'html_after_fields' => '',
'submit_value' => 'Submit Post',
'updated_message' => 'Saved!',
'uploader' => 'wp',
'return' => '/'
)); ?>
Yes I have ACFPro V5.
Andy
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.