WordPress分类的描述是一个 textarea ,只支持纯文本信息。
怎样才能把 textarea 变成一个 富文本编辑器呢?
其实,还是要用到为分类添加属性的钩子 category_edit_form_fields 和 category_add_form_fields 。先利用这两个钩子,添加一个和原来textarea表单名称一样的富文本编辑器。然后,再把之前的textarea删掉。
参考代码如下:
add_action("category_edit_form_fields", 'edit_form_fields_example', 10, 2);
add_action("category_add_form_fields", 'add_form_fields_example', 10, 2);
function edit_form_fields_example($term){
?>
<tr valign="top">
<th scope="row"><?php _e('描述','salong'); ?></th>
<td>
<?php wp_editor(html_entity_decode($term->description), 'description', array('media_buttons' => true,'quicktags'=>true)); ?>
<script>
// 删除原来的textarea
jQuery(window).ready(function(){
jQuery('label[for=description]').parent().parent().remove();
});
</script>
</td>
</tr>
<?php
}
function add_form_fields_example(){
?>
<tr valign="top">
<th scope="row"><?php _e('描述','salong'); ?></th>
<td>
<?php wp_editor('', 'description', array('media_buttons' => true,'quicktags'=>true)); ?>
<script>
// 删除原来的textarea
jQuery(window).ready(function(){
jQuery('label[for=tag-description]').parent().remove();
});
</script>
</td>
</tr>
<?php
}
-
WordPress6.5新功能-声明式插件依赖在 WordPress 6.5 中,插件依赖变简单了
-
WordPress 6.5 新功能 - 支持 AVIFWordPress 6.5 新功能 - 支持 AVIF
-
WordPress 6.5移除区块样板菜单项的方法WordPress 6.5新增的区块样板菜单项,可将不同区块组合成一个新的区块模板,方便重复使用。
-
WordPress做多语言企业网站近期常用小伙伴问追格小编,有没有计划做双语WordPress企业官网主题。
-
WordPress插件:LiteSpeed Cache 缓存插件LiteSpeed Cache是一款实用的WordPress缓存插件,专为使用LiteSpeed服务器的用户设计。它能显著提高网站加载速度,改善用户体验。
-
追格企业官网主题多语版惊艳上线:WordPress模块化DIY,重塑企业官网时代追格(zhuige.com)旗下WordPress企业官网主题(多语版)正式发布,多模块巧妙组合,打造非凡页面,简约或华丽,皆显震撼。官网新风尚,颠覆传统设计,C位出道,惊艳全场,重新定义WordPress企业官网。
暂无评论,抢个沙发...