Wordpress acf_表单未在CPT中发布字段
如果我将帖子状态设置为“发布”(如下所示),此表单将创建帖子,但此帖子类型的我的acf字段(某些字段应自动填充)不会添加到数据库中 如果我将post状态设置为“草稿”,此表单将创建草稿-如果我编辑并保存该草稿,则一切正常 有什么想法吗 谢谢,RichardWordpress acf_表单未在CPT中发布字段,wordpress,advanced-custom-fields,custom-post-type,Wordpress,Advanced Custom Fields,Custom Post Type,如果我将帖子状态设置为“发布”(如下所示),此表单将创建帖子,但此帖子类型的我的acf字段(某些字段应自动填充)不会添加到数据库中 如果我将post状态设置为“草稿”,此表单将创建草稿-如果我编辑并保存该草稿,则一切正常 有什么想法吗 谢谢,Richard <?php acf_form_head(); ?> <?php get_header(); ?> <div id="primary" class="rs-add-forms"
<?php acf_form_head(); ?>
<?php get_header(); ?>
<div id="primary" class="rs-add-forms">
<div id="content" class="site-content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php acf_form(array(
'post_id' => 'new_post',
'post_title' => true,
'new_post' => array(
'post_type' => 'people',
'post_status' => 'publish'
),
'fields' => array('field_5ed5c2215be79',),
'submit_value' => 'Create Person',
'html_submit_button' => '<input type="submit" class="rs-add-button" value="%s" />',
'updated_message' => false
)); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
由于acf_form
调用选项数组中字段的值
键,因此您应该尝试结构化数据
因此,您可以修改为
'fields' => array(
array(
'key' => 'field_5ed5c2215be79',
'name' => 'Form Field Title',
'type' => 'registered_acf_fieldtype',
'parent' => '[probably optional]'
)
),
谢谢Cameron,这听起来很有希望,但是我被数组'fields'=>array('field5ed5c2215be79')弄糊涂了,
是一个不同字段的数组,但是你将它显示为一个字段的不同元素的数组这很有意义,除了我有需要“初始化”的字段,但我不希望它们显示在表单中。有没有办法做到这一点?隐藏输入类型,没有?
'fields' => array(
array(
'key' => 'field_5ed5c2215be79',
'name' => 'Form Field Title',
'type' => 'registered_acf_fieldtype',
'parent' => '[probably optional]'
)
),