2017-08-24 144 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);