在前台获取管理区域编辑器

时间:2018-03-07 作者:iMan Biglari

我是WordPress开发的新手,如果这是一件简单的事情,我深表歉意。

我已经创建了几种自定义帖子类型,我想让用户从前端添加/编辑内容。我觉得这很容易。打个电话就行了wp_editor() 它会知道要显示哪种类型的控件(我使用的是高级自定义字段),但是wp_editor() 为每个帖子显示一个简单的文本框,无论帖子类型如何。我知道有很多插件声称它们可以让用户从前端编辑帖子,但我更喜欢在前端显示内置编辑器。是否有其他函数可以调用来代替wp_editor() 我错过了什么?

1 个回复
最合适的回答,由SO网友:Sally CJ 整理而成

wp\\u editor()为每篇文章显示一个简单的文本框

它实际上不是一个“简单文本框”=),因为wp_editor() 允许您转换/转动textarea 使用富文本/所见即所得编辑器TinyMCE library.

我想让用户从前端添加/编辑内容

因为您使用的是高级自定义字段(ACF),所以an easy way to do that, 基本上是通过使用acf_form(). 并基于上的示例this page, 下面是一个示例页面模板,您可以将其用于2017主题:

<?php
/**
 *  Template Name: ACF Create Post
 */

acf_form_head();

get_header(); ?>

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

            <?php while ( have_posts() ) : the_post(); ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <header class="entry-header" style="width: 100%;">
                    <?php the_title( \'<h1 class="entry-title">\', \'</h1>\' ); ?>
                    <?php twentyseventeen_edit_link( get_the_ID() ); ?>
                </header><!-- .entry-header -->
                <div class="entry-content" style="width: 100%;">
                    <?php
                        the_content();

                        acf_form( array(
                            \'post_id\'      => \'new_post\',
                            \'field_groups\' => array( 1858 ),
                            \'submit_value\' => \'Create Post\',
                        ) );
                    ?>
                </div><!-- .entry-content -->
            </article><!-- #post-## -->
            <?php endwhile; ?>

        </main><!-- #main -->
    </div><!-- #primary -->
</div><!-- .wrap -->

<?php get_footer();
希望有帮助!

结束

相关推荐

Front-End Post Submission

我正在尝试添加一个表单,用户可以从前端提交帖子。我正在学习本教程:http://wpshout。com/wordpress从前端提交帖子/我正在做的是添加this code 到我的一个页面模板。表单显示正常,但当我单击“提交”按钮时,它会显示“Page not found error“”许多评论者说这不起作用。谁能给我指出正确的方向吗?代码是否不完整?有缺陷吗?我做错什么了吗?谢谢Towfiq I。