如何使用wp编辑器

我是wordpress主题开发的新手…

我知道要在wordpress主题中创建主题选项, 但是现在我想使用wordpress的WYSIWYG编辑器wp_editor(), 我已经阅读了一些有关此内容的文章, 但我做不到…

这是我的代码:

    add_settings_field('tinytxt', 'WYSIWYG: ', array($this, 'tinytxt'), 'oditer_theme_options', 'jd_theme_options_main_section');



public function tinytxt() {

     wp_editor("{$this->options['tinytxt']}", 'tinytxtboom');
}

以及如何从数据库中检索保存的内容, 我知道使用get_option()…

提前致谢…


#1


你需要为你的WordPress编辑器输入一个名称, 以便它可以保存值。

wp_editor( $this->options['tinytxt'], 'tinytxtboom', array(
    'textarea_name' => 'jd_theme_options[tinytxt]'
) );

这将使隐藏的文本区域wp_editor使用名称来提交表单。 jd_theme_options将第二个参数与register_setting匹配, tinytxt是要在其中保存值的选项键。

我认为这就是你所需要的。如果遇到问题, 请发表评论。我明天回来检查。

你也可以尝试使其仅在简单的textarea上运行, 然后尝试使wp_editor运行。

来源:

https://www.srcmini02.com/67384.html

微信公众号
手机浏览(小程序)
0
分享到:
没有账号? 忘记密码?