个性化阅读
专注于IT技术分析

如何使用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运行。

赞(0)
未经允许不得转载:srcmini » 如何使用wp编辑器

评论 抢沙发

评论前必须登录!