使用wp_editor编辑前端的帖子标题

时间:2014-07-31 09:22:56

标签: php wordpress post frontend

我试图添加用户编辑前端帖子内容的功能。

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

<?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>

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

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

1 个答案:

答案 0 :(得分:1)

要编辑标题,您应使用$ post-&gt; post_title而不是post_content,因为post_content是您网页的正文

相关问题