可是wordpress默认的编辑器中没有这个按钮哇。不要着急,本节高时银博客就带大家一起来给文章编辑器添加一个分页按钮。
在主题的function.php函数模板文件里添加如下代码:
代码如下 |
复制代码 |
//在 WordPress 编辑器添加“下一页”按钮
add_filter(‘mce_buttons’,'wpdaxue_add_next_page_button’);
function wpdaxue_add_next_page_button($mce_buttons) {
$pos = array_search(‘wp_more’,$mce_buttons,true);
if ($pos !== false) {
$tmp_buttons = array_slice($mce_buttons, 0, $pos+1);
$tmp_buttons[] = ‘wp_page’;
$mce_buttons = array_merge($tmp_buttons, array_slice($mce_buttons, $pos+1));
}
return $mce_buttons;
}
|
这样我们就完成了文章分页按钮的添加,在文章编辑器就会多出一个文章分页按钮出来(如下图)。以后,如果文章过长,只需在需要分页的地方插入这个按钮就可以分页显示了。
