donglang6656 2014-08-20 15:25
浏览 96

Wordpress - 高级自定义字段。 前端表单添加新帖子不显示

I am trying to display a form on the front end. It seems one can do that, as specified here: http://www.advancedcustomfields.com/resources/acf_form/

I have the field group all set up to display for post type = 'byc_cure'. The form is displaying on the back end. Here is the code by which I am attempting to display the form on the front end:

<?php acf_form_head(); ?>
    <?php get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">

            <?php /* The loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>

                <?php acf_form(array(
                    'post_id'       => 'new_post',
                    'new_post'      => array(
                        'post_type'     => 'byc_cure',
                        'post_status'       => 'publish'
                    ),
                    'submit_value'      => 'Publish'
                )); ?>

            <?php endwhile; ?>

        </div><!-- #content -->
    </div><!-- #primary -->

I put this code in a page template and made a page that uses this template.However, when I click a link that takes me to this page, the form does not display. The only thing that displays is a 'Publish' button.

Will it make a difference if I put it in the single-byc_cure.php file? Or, do I need to specify that this form should come up when page = page.php. When I tried that however, an update button displays (just like on the back end). How do I modify the code so that the form displays, I can customize the text on the submit button and ACF knows that when the form is submitted it should create a new post of type 'byc_cure'?

Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongwei3172 2015-04-23 11:00
    关注

    To display ACF on frontend use this: https://wordpress.org/plugins/acf-frontend-display/

    To process your form (example: create post, send email or register user) use this: https://wordpress.org/plugins/forms-actions/

    评论

报告相同问题?

悬赏问题

  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致