很多朋友總喜歡給長一點的文章進行分頁,可是默認狀況下,在WordPress的編輯器中,是沒有顯示「下一頁」按鈕的,每次都要手動添加分頁代碼 <!–nextpage–>是一件很是費力的事,其實,咱們只要在當前主題的 functions.php 添加下面的代碼,就能夠顯示「下一頁」按鈕啦:php
若是你是 WP 4.2 或以上的版本,能夠使用下面的代碼:html
1 2 3 4 5 6 7 8 9 10 11 |
/*-----------------------------------------------------------------------------------*/ # 在 WordPress 編輯器添加「下一頁」按鈕 # https://www.wpdaxue.com/add-next-page-button-wordpress-post-editor.html /*-----------------------------------------------------------------------------------*/ add_filter( 'mce_buttons', 'cmp_add_page_break_button', 1, 2 ); function cmp_add_page_break_button( $buttons, $id ){ if ( 'content' != $id ) return $buttons; array_splice( $buttons, 13, 0, 'wp_page' ); return $buttons; } |
效果以下:編輯器
===如下爲舊版本代碼===========wordpress
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/** * 在 WordPress 編輯器添加「下一頁」按鈕 * https://www.wpdaxue.com/add-next-page-button-wordpress-post-editor.html */ 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; } |
最終效果以下圖所示:post
賞htm