I have set up a custom post type, ‘Files’ and have created custom fields which has the following fields:
Title, File upload, Thumbnail upload, Category.
I have used the following code to get this displaying on a page on the front end:
<?php acf_form_head(); get_header(); ?> <div id="primary"> <div id="content" role="main"> <?php /* The loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <h1><?php the_title(); ?></h1> <?php acf_form(array( 'id' => 'File / Media Upload Form', 'post_id' => 'new_post', 'post_title' => true, 'post_content' => true, 'submit_value' => 'Add file', 'new_post' => array( 'post_type' => 'files', 'post_status' => 'publish' ) )); ?> <?php endwhile; ?> </div><!-- #content --> </div><!-- #primary --> <?php get_footer(); ?>
The custom post type also shows up in the back end automatically and if I use this to post, it works but the form on the front end does not work. It submits without any errors but nothing is posted in ‘Files’ or in the POST table in the database. The images are submitted to the media library.
Can someone please help me troubleshoot?
That’s weird. I’ve just tested your form code and it was working great. Maybe there’s a function in your theme or plugins that caused this issue. Could you please try to reproduce the issue on one of the WordPress’ stock themes (like Twenty Sixteen) with other plugins deactivated? If it disappears, then you can activate the theme and plugins one by one to see which one causes the issue.
Version 5 is another name for ACF PRO and version 4 is the free version. This page should give you more idea about it: https://www.advancedcustomfields.com/resources/acf-pro/. If you want to use ACF version 5, please check this page out: http://www.advancedcustomfields.com/pro.
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!
© 2022 Advanced Custom Fields.