2016-09-28 26 views
0

需要你的幫助球員。我有一個頁面,通過Private Content插件創建一個簡單的textarea字段。我需要做的是通過向它添加富文本編輯器來改進該textarea,我認爲標準WP一應該沒問題。替換WP編輯器創建的textarea插件

您能否直接指導我需要哪些代碼以便過去以及我應該在哪裏做?正如你所看到的,編碼並不是我的強項。嘗試谷歌和搜索這裏和那裏有一些結果,但它不夠清楚,我沒有正確實施。

希望你的幫助!

回答

0

使用功能

wp_editor($content, $editor_id, $settings = array()); 

可以顯示WordPress默認編輯器。快速(unsanitized)例如:

您的表單內容(不要忘記加上<form>標籤):

<?php wp_editor('I am a prefilled sample text', 'editorname' ?> 

的腳本,閱讀:

$editor_content = $_POST['editorname'] 
//do stuff, perhaps put to database 
save_to_db($editor_content) //for example 

幾個簡單的事情要注意

  • 編輯器呈現aka直接回顯,因此您不必添加echo
  • $editor_id只能只有只能包含下邊框字母。沒有下劃線。

,但有一個在這裏看自己:https://codex.wordpress.org/Function_Reference/wp_editor

0

使用此代碼:

wp_editor($內容 '的content_id',陣列( 'textarea_name'=> '的content_id', 'editor_class'= >'requiredField','textarea_rows'=>'6','media_buttons'=> true,'tinymce'=> true));

+0

我應該在哪裏插入這段代碼? – Ted

+0

用上面的代碼替換文本區域html,並在上面放置這段代碼$ content = get_post_meta($ _ GET ['post'],'post_meta _name',true); –