0

需要你们的帮助。我有一个页面,通过 Private Content 插件我创建了一个简单的 textarea 字段。我需要做的是通过添加富文本编辑器来改进该文本区域,我认为标准的 WP 应该没问题。

您能否提供直接说明我需要过去哪些代码以及我应该在哪里做?如您所见,编码不是我的强项。尝试 google 并在此处搜索并有一些结果,但我无法正确实施。

希望得到您的帮助!

4

2 回答 2

0

使用此代码:

wp_editor($content, 'content_id', array('textarea_name' => 'content_id', 'editor_class'=>'requiredField', 'textarea_rows'=>'6', 'media_buttons' => true ,'tinymce' =>真的) );

于 2016-09-28T10:34:51.580 回答
0

使用功能

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

您可以显示默认的 wordpress 编辑器。快速(未消毒)示例:

您的表单内容(不要忘记添加<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

需要注意的一些快速事项

  • 编辑器被渲染也就是直接回显,所以你不必添加echo
  • $editor_id只能包含小写字母。_ 没有下划线。

但在这里看看自己:https ://codex.wordpress.org/Function_Reference/wp_editor

于 2016-09-28T08:05:49.060 回答