hen*_*ght 5 php wordpress tinymce
我想用wp_editor()替换textarea
我的textarea表单元素如下所示:
<textarea name="post_text" id="post_text" rows="3"><?php echo $content; ?></textarea>
Run Code Online (Sandbox Code Playgroud)
然后我有:
wp_editor( $content, 'post_text' );
Run Code Online (Sandbox Code Playgroud)
我得到的问题是textarea形式和页面上输出的wp_editor textarea.为什么两个textareas都显示?我只需要一个textarea来显示.一切都很好,我只有2 textareas显示这个问题.
编辑:是否就像display: none;
在我的表单的textarea上放一个简单所以只显示wp_editor()textarea?这似乎有效,但感觉有点hackish.
我找到了解决方案.您可以使用第三个参数传递参数数组.现在这很明显,如法典中所述:http://codex.wordpress.org/Function_Reference/wp_editor
什么是有点混乱(我的问题的根源)是$ editor_id可能只包含小写字母.因此,如果您的表单处理脚本正在寻找带有下划线的内容(就像我的那样),那么您需要这样做:
$settings = array( 'textarea_name' => 'post_text' )
wp_editor( $content, $editor_id, $settings );
Run Code Online (Sandbox Code Playgroud)
请注意,你不能这样做:
wp_editor( $content, 'post_text' );
Run Code Online (Sandbox Code Playgroud)
这是我出错的地方.