WordPress自带的文章编辑器存在一些缺陷,比如chrafz认为最不方便的地方就在于没有设置文字字号的功能,但是Wordpress使用的编辑器是拥有这些功能的,只是没有被启用。好在可以通过在主题的functions.php里添加以下代码为它启用这些功能。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
function add_editor_buttons($buttons) { $buttons[] = 'fontselect'; $buttons[] = 'fontsizeselect'; $buttons[] = 'backcolor'; $buttons[] = 'underline'; $buttons[] = 'hr'; $buttons[] = 'sub'; $buttons[] = 'sup'; $buttons[] = 'cut'; $buttons[] = 'copy'; $buttons[] = 'paste'; $buttons[] = 'cleanup'; $buttons[] = 'wp_page'; $buttons[] = 'newdocument'; return $buttons; } add_filter("mce_buttons_2", "add_editor_buttons"); //添加中文字体 function custum_fontfamily($initArray){ $initArray['font_formats'] = "微软雅黑='微软雅黑';宋体='宋体';黑体='黑体';仿宋='仿宋';楷体='楷体';隶书='隶书';幼圆='幼圆';"; return $initArray; } add_filter('tiny_mce_before_init', 'custum_fontfamily'); |
启用后的效果如下:

为WordPress文章编辑器添加更多功能 张弦先生のchrafz.com
评论4