WordPress默认提供一个html /文本编辑器,但如何在我的WordPress页面添加额外的文本/ html编辑器? 我想在WordPress中添加额外的html /文本编辑器以从后端添加内容。 以及如何显示特定页面。
答案 0 :(得分:1)
将下面的代码粘贴到您的function.php文件中。
/*Add Text Editor start*/
function CreateTextEditor()
{
$screen = 'page';
add_meta_box('display_editor','Secound Editor','displaytexteditor',$screen,'normal','high');
}
add_action( 'add_meta_boxes', 'CreateTextEditor' ) ;
function displaytexteditor($post)
{
global $wbdb;
$metaeditor = 'metaeditor';
$displayeditortext = get_post_meta( $post->ID,$metaeditor, true );
?>
<h2>Secound Editor</h2>
<?php
$args = array("textarea_rows" => 5, "textarea_name" => "editor_content_2", "editor_class" => "my_editor_custom");
wp_editor($displayeditortext, "my_editor_2", $args);
}
function saveshorttext($post)
{
$editor = $_POST['editor_content_2'];
update_post_meta( $post, 'metaeditor', $editor);
}
add_action('save_post','saveshorttext');
function new_editor_content($content)
{
global $post;
echo $meta4 = get_post_meta($post->ID, 'metaeditor', true );
return $content;
}
add_filter('the_content', 'new_editor_content');
/*Add Text Editor End*/