jquery - 如何使用Jquery加载wp_editor?

标签 jquery wordpress wp-editor

我想在我的自定义插件中使用 jquery 动态添加 WordPress 编辑器,如下所示:

 <?php

  $content = '';

  $editor_id = 'mycustomeditor';      

?>

 $('#container').append('<?php wp_editor( $content, $editor_id );?>');

我收到错误:

SyntaxError: missing ) after argument list

...-active"><link rel='stylesheet' id='editor-buttons-css'  href='http://localhost 

我还尝试了以下代码(这里我已将单引号替换为双引号):

  <?php

     $content = '';

     $editor_id = 'mycustomeditor';      

  ?>

  $('#container').append("<?php wp_editor( $content, $editor_id );?>");

我收到错误:

 SyntaxError: missing ) after argument list   


$('#container').append("<div id="wp-mycustomeditor-wrap" class="wp-core-ui wp-ed...

如果您有任何解决方案,请告诉我。

提前致谢

最佳答案

我知道迟到的答案。但这会帮助其他人。试试这个 jQuery 插件。

https://github.com/anteprimorac/js-wp-editor

您可以使用如下简单的

    jQuery(document).ready(function (){

        jQuery('#container').wp_editor();

    });

关于jquery - 如何使用Jquery加载wp_editor?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25644967/

相关文章:

html - wp_editor 始终将 <br> 转换为 <p> </p>

javascript - 使用 Pickadate.js 时出现问题 - 显示效果不佳

javascript - 使用 jquery/ajax 在 CodeIgniter 的 Controller 中调用函数

css - Elementor 更改按钮悬停在列上的部分图像

javascript - 显示按钮 B 时仅显示按钮 A

javascript - 由于自定义 js 文件,编辑器的工具栏丢失

javascript - 不使用 'table'创建动态html表

javascript - 添加图像链接会破坏 jquery slider ,请帮忙!

php - 如何使用 corcel 在 wordpress 中获取选定的主页?