wordpress文章分頁(yè)方法總結(jié)

字號(hào):


    編輯文章的時(shí)候,切換到html輸入,然后在需要分頁(yè)的地方輸入
    代碼如下:
    <!--nextpage-->
    有的主題僅僅添加了標(biāo)簽還不行,還需要主題能支持分頁(yè)功能,如果你添加了分頁(yè)標(biāo)簽,但主題沒(méi)有分頁(yè)的話,那你的主題就不支持分頁(yè)功能,需要自己添加。
    添加方法:打開(kāi)文章 模板(一般是主題的single.php)文件,如果不是single.php文件的話,需要自己去找到文章模板。。
    找到下面的函數(shù)
    代碼如下:
    <?php the_content(); ?>
    然后在它的后面添加代碼
    代碼如下:
    <?php
    wp_link_pages( array( 'before' => '<div>' . __( '頁(yè)碼' ), 'after' => '</div>' ) );
    ?>
    雖然實(shí)現(xiàn)了分頁(yè)功能但是不是很方便,因?yàn)榉猪?yè)標(biāo)簽的代碼每次都需要手動(dòng)輸入
    過(guò)程:1、找到wp-includes/js/quicktags.js ,在其中找到下面這個(gè)javascript代碼:
    代碼如下:
    edButtons[edButtons.length]=new edButton(“ed_more”,”more”,”<!–more–>”,”",”t”,-1);
    在這個(gè)代碼的后面加上如下代碼:
    代碼如下:
    edButtons[edButtons.length]=new edButton(“ed_next”,”page”,”<!–nextpage–>”,”",”p”,-1);
    2. 繼續(xù)在wp-includes/js/quicktags.js 中找到如下代碼:
    代碼如下:
    j.Buttons[j.Buttons.length]=new edButton(a+”_more”,”more”,”<!–more–>”,”",”t”,-1);
    在后面加上如下代碼:
    代碼如下:
    j.Buttons[j.Buttons.length]=new edButton(a+”_next”,”page”,”<!–nextpage–>”,”",”p”,-1);
    OK ,此文件可以保存了。
    3. 找到wp-includes/js/quicktags.dev.js ,找到下面代碼
    代碼如下:
    /*
    edButtons[edButtons.length] =
    new edButton(‘ed_next’
    ,’page’
    ,’<!–nextpage–>’
    ,”
    ,’p’
    ,-1
    );
    */
    去掉注釋,最后是下面的樣子
    代碼如下:
    edButtons[edButtons.length] =
    new edButton(‘ed_next’
    ,’page’
    ,’<!–nextpage–>’
    ,”
    ,’p’
    ,-1
    );
    4. 找到wp-admin/includes/post.php ,找到下面代碼:
    代碼如下:
    ‘link’, ‘unlink’, ‘wp_more’,
    在其后面添加代碼:
    代碼如下:
    ‘wp_page’,
    OK,當(dāng)你打開(kāi)編輯器寫文章的時(shí)候,可視化狀態(tài)下就會(huì)出現(xiàn)分頁(yè)符的按鈕,在你想插入頁(yè)碼的時(shí)候點(diǎn)擊此按鈕就行了