【问题标题】:using wp_editor to edit post title on the front end使用 wp_editor 在前端编辑帖子标题
【发布时间】:2014-07-31 09:22:56
【问题描述】:

我正在尝试为用户添加在前端编辑帖子内容的功能。

我在每个帖子之后的循环中添加以下代码:

<?php
$post_id = get_the_ID();
$post = get_post( $post_id, OBJECT, 'edit' );

$content = $post->post_content;
$editor_id = 'editpost';

$editor_args = array(
'media_buttons' => false,
'editor_class' => my_editor,
'textarea_rows' => 10,
'wpautop' => false,
'tinymce' => array( 
'content_css' => get_stylesheet_directory_uri() . '/custom/editor-style_single.css' 
    ) 
);

?>
<div id="inline_editor">
<?php wp_editor( $content, $editor_id, $editor_args ); ?>
</div>

似乎我可以编辑帖子内容本身,但我无法管理编辑器以显示帖子标题/帖子名称。

如何从前端编辑帖子标题?

【问题讨论】:

    标签: php wordpress post frontend


    【解决方案1】:

    要编辑标题,您应该使用 $post->post_title 而不是 post_content,因为 post_content 是页面的正文

    【讨论】:

      猜你喜欢
      • 2014-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-15
      相关资源
      最近更新 更多