我正在尝试为用户添加在前端编辑帖子内容的能力。
我在每个帖子之后的循环中添加以下代码:
<?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>
似乎我可以编辑帖子内容本身,但我不能管理编辑器显示帖子标题/帖子名称。
如何从前端编辑文章标题?
对于编辑标题,您应该使用$post->post_title而不是post_content,因为post_content是页面的主体