I’ve spent the last two days trying to build “form to post” mechanism for my music website, but am not getting anywhere, so I’m posting it here.
Basically, I created a custom form with ACF Pro (v. 5.4.7) that includes various album-related information (name, artist, description, cover image, year published, length, rating).
I built an add-music.php page that is supposed to contain a form to enter a new album and have it posted to the site, and a single-music.php for displaying those posts.
I also use the Custom Post Types UI plugin for creating the “music” post types.
The closest I’ve come to making it work is this:
<?php
acf_form_head();
[...]
$arguments = array(
'field_groups' => array(123),
'return' => home_url('thanks'),
'post_id' => 'new_post',
'post_title' => true,
'new_post' => array(
'post_status' => 'publish',
'post_type' => 'music',
'post_title' => the_field('albumtitle')
),
'submit_value' => 'Add Album'
);
acf_form($arguments);
The problem is that this doesn’t really do what I thought it would do.
Instead of using my ACF-created ‘albumtitle’ field that is part of form 123, it adds a completely new and unrelated “title” field to the top of my form.
The title entered there is then actually used as the title of the new post, but the the field from my form is ignored. If I change the code to not display that field but only the actual form field the WP title is not adjusted.
I could remove my own title field of course, but then I still wouldn’t know how to access all the other values.
Thanks for your help!