如何使用wordpress编辑器

问题描述 投票:0回答:2
 - wp_register_script( 'tinymce-min-js',
   "//cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.1/tinymce.min.js"); 
       wp_enqueue_script( 'tinymce-min-js' );

    <textarea name="message"></textarea>

     tinymce.init({ 
                toolbar1: "code | preview | fullscreen | emotEventns | blockquote | cut copy paste | undo redo removeformat | save",
                toolbar2: "table | image | link | charmap | hr | media | alignleft aligncenter alignright alignjustify | outdent indent",
                toolbar3: "fontselect fontsizeselect | forecolor backcolor | bold italic underline strikethrough | subscript superscript",
                plugins: "code advlist fullscreen media preview table image link textcolor charmap emotEventns",
                menubar: false, 
                width: 800,
                height: 470,
                resize: false,
                fullpage: false,    
                selector: "textarea"
            });

我试过这个,但我没有得到编辑。我想用文本区编辑器。请尝试解决这个问题。先感谢您

wordpress
2个回答
0
投票

试试这个代码。

<script>
    jQuery( document ).ready( function( $ ) {
            tinymce.init({ 
                toolbar1: "code | preview | fullscreen | emotEventns | blockquote | cut copy paste | undo redo removeformat | save",
                toolbar2: "table | image | link | charmap | hr | media | alignleft aligncenter alignright alignjustify | outdent indent",
                toolbar3: "fontselect fontsizeselect | forecolor backcolor | bold italic underline strikethrough | subscript superscript",
                //plugins: "code advlist fullscreen media preview table image link textcolor charmap emotEventns",
                menubar: false, 
                width: 800,
                height: 470,
                resize: false,
                fullpage: false,    
                selector: "textarea"
            });
    });

</script>

jQuery( document ).ready( function( $ ) {
				tinymce.init({ 
					toolbar1: "code | preview | fullscreen | emotEventns | blockquote | cut copy paste | undo redo removeformat | save",
					toolbar2: "table | image | link | charmap | hr | media | alignleft aligncenter alignright alignjustify | outdent indent",
					toolbar3: "fontselect fontsizeselect | forecolor backcolor | bold italic underline strikethrough | subscript superscript",
					//plugins: "code advlist fullscreen media preview table image link textcolor charmap emotEventns",
					menubar: false, 
					width: 800,
					height: 470,
					resize: false,
					fullpage: false,    
					selector: "textarea"
				});
		});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.1/tinymce.min.js"></script>
<textarea></textarea>
<script>

    </script>

0
投票

不确定您尝试显示编辑器的位置,但使用内置的wp_editor函数!

看到这里wp_editor&这里tutsplus.com

$settings = array(
   'wpautop' => false,       // auto add p tags to paragraphs
   'media_buttons' => false, // show or hide the media upload button
   'textarea_rows' => 10,    // how many rows you want in the text area
   'teeny' => false          // show or hide the compact editor view
);

$textAreaContent = 'get the data from database';
$editorID = 'id_of_the_editor';

wp_editor( $textAreaContent, $editorID, $settings );

这应该产生一个很好的文本编辑器,如...

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.