2017-08-24 81 views
1

我目前正在建立一个插件,需要我删除TinyMCE编辑器,并用文本区域进行替换。发布内容未显示在编辑帖子textarea中。 (WordPress的)

下面的代码帮我要从管理区域TinyMCE的编辑器:

function wpdocs_remove_post_type_support() { 
    remove_post_type_support('post', 'editor'); 
} 

add_action('init' ,'wpdocs_remove_post_type_support'); 

然后添加自己的textarea用下面的代码:

function myprefix_edit_form_advanced() { 


require('texteditor.html'); 

} 

add_action('edit_form_after_title', 'myprefix_edit_form_advanced'); 

我texteditor.html样子这个:

<html> 

<head> 

</head> 

<body> 

<div> 
<textarea id="text" name="post_content" data-placeholder="start writing..."> 


</textarea> 

    </div> 
</body> 
</html> 

毕竟上面的代码,我能够使用textarea保存内容,但是当我到了编辑帖子区域,textarea字段中没有显示帖子内容。我的问题是,是否有任何功能可以调用,以确保文本内容显示在textarea中。

我非常感谢任何帮助。

谢谢。

回答

2

您可以删除所有的代码,并替换为:

function replace_tinymce_by_textarea($settings, $editor_id) { 
if ($editor_id == 'content') { 
    $settings['tinymce'] = false; 
    $settings['quicktags'] = false; 
    $settings['media_buttons'] = false; 
} 
return $settings; 
} 

add_filter('wp_editor_settings', 'replace_tinymce_by_textarea', 10, 2);