如何解决acf_form无法在CPT中发布字段
如果我将发布后的状态设置为“发布”(如下所示),则此表单会创建该发布,但是我针对此发布类型的acf字段(某些字段应自动填充)不会添加到数据库中
如果我将状态设置为“草稿”,则此表单会创建草稿-如果我编辑并保存该草稿,一切都很好
有什么想法吗?
谢谢理查德
<?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
对options数组中的fields
键的值调用了acf_add_local_field
,因此您应该尝试构造数据like the function parses defaults for,internally。
// Apply default properties needed for import.
$field = wp_parse_args($field,array(
'key' => '','name' => '','type' => '','parent' => '',));
因此,您可以修改为
'fields' => array(
array(
'key' => 'field_5ed5c2215be79','name' => 'Form Field Title','type' => 'registered_acf_fieldtype','parent' => '[probably optional]'
)
),
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。