【问题标题】:Unable to create a front end form with ACF, WordPress, No ACF Frontend Display Plugin?无法使用 ACF、WordPress、没有 ACF 前端显示插件创建前端表单?
【发布时间】:2015-11-06 22:41:29
【问题描述】:

我正在尝试在我正在使用 WordPress 构建的 Intranet 的主页上创建一个表单。我正在尝试使用高级自定义字段 (ACF) 创建表单。我已按照此处 ACF 文档中提供的说明进行操作:http://www.advancedcustomfields.com/resources/using-acf_form-to-create-a-new-post/

我已经阅读了几个答案,其中人们使用了一个名为 ACF 前端显示插件的插件,其 URL 为:https://wordpress.org/plugins/acf-frontend-display。这个插件好像不存在了。我需要为 ACF Pro 准备吗?

我正在尝试在我的front-page.php 中执行此操作。我在get_header();上方添加了这一行。

acf_form_head();

我在希望表单所在的位置添加了这个:

acf_form(array(
    'post_id'       => 'new_post',
    'new_post'      => array(
        'post_type'     => 'post',
        'post_status'   => 'publish'
    )
));

这是我尝试查看表单时遇到的错误,请注意出现提交按钮:

感谢您的帮助。

【问题讨论】:

    标签: php wordpress advanced-custom-fields


    【解决方案1】:

    从示例中,您至少需要它是这样的(您缺少标题和内容):

        acf_form(array(
            'post_id'       => 'new_post',
            'post_title'    => true,
            'post_content'  => true,
            'new_post'      => array(
                'post_type'     => 'post',
                'post_status'   => 'publish'
            )
        ));
    

    但这也应该包含在循环中(即<?php while ( have_posts() ) : the_post(); ?>)。

    【讨论】:

    • 你能在上下文中提供更多代码吗?
    • v5 的结构也不同于 v4。您需要 v4 的自定义函数。
    【解决方案2】:

    问题是我使用的是免费版本的高级自定义字段(在撰写本文时)是4.4.2。 ACF 的所有在线文档都默认为版本 5 文档。 ACF Pro 版本为5.2.9

    版本4不支持创建新帖,必须使用专业版才能使用此功能创建新帖。

    http://www.advancedcustomfields.com/pro/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-17
      • 2014-01-29
      • 1970-01-01
      • 2020-06-04
      • 2014-01-26
      • 2014-03-20
      相关资源
      最近更新 更多