wordpress文章分頁方法總結

字號:


    編輯文章的時候,切換到html輸入,然后在需要分頁的地方輸入
    代碼如下:
    <!--nextpage-->
    有的主題僅僅添加了標簽還不行,還需要主題能支持分頁功能,如果你添加了分頁標簽,但主題沒有分頁的話,那你的主題就不支持分頁功能,需要自己添加。
    添加方法:打開文章 模板(一般是主題的single.php)文件,如果不是single.php文件的話,需要自己去找到文章模板。。
    找到下面的函數(shù)
    代碼如下:
    <?php the_content(); ?>
    然后在它的后面添加代碼
    代碼如下:
    <?php
    wp_link_pages( array( 'before' => '<div>' . __( '頁碼' ), 'after' => '</div>' ) );
    ?>
    雖然實現(xiàn)了分頁功能但是不是很方便,因為分頁標簽的代碼每次都需要手動輸入
    過程:1、找到wp-includes/js/quicktags.js ,在其中找到下面這個javascript代碼:
    代碼如下:
    edButtons[edButtons.length]=new edButton(“ed_more”,”more”,”<!–more–>”,”",”t”,-1);
    在這個代碼的后面加上如下代碼:
    代碼如下:
    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,當你打開編輯器寫文章的時候,可視化狀態(tài)下就會出現(xiàn)分頁符的按鈕,在你想插入頁碼的時候點擊此按鈕就行了