好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

wordpress 文章分页方法总结 - WordPress

wordpress 文章分页方法总结

在wordpress中的文章分页我们可以很简单的直接手动在编辑器中这样写这样wordpress会自动给我们的长文章分页了,除了这种方法之还我们可以在编辑器中进行简单修改就可以实现在编辑器中直接加个分页按钮,下面我来分别介绍.

编辑文章的时候,切换到html输入,然后在需要分页的地方输入:<!--nextpage-->  

有的主题仅仅添加了<!--nextpage-->标签还不行,还需要主题能支持分页功能,如果你添加了分页标签,但主题没有分页的话,那你的主题就不支持分页功能,需要自己添加。

添加方法: 打开文章 模板(一般是主题的single.php)文件,如果不是single.php文件的话,需要自己去找到文章模板.

找到下面的函数,代码如下:

<?php the_content(); ?> 然后在它的后面添加如下代码:

<?php   wp_link_pages(  array (  'before'  =>  '<div class="page-link">'  . __(  '页码'  ),  'after'  =>  '</div>'  ) );   ?>  

虽然实现了分页功能但是不是很方便,因为分页标签的代码每次都需要手动输入

过程: 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.继续在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,当你打开编辑器写文章的时候,可视化状态下就会出现分页符的按钮,在你想插入页码的时候点击此按钮就行了.

查看更多关于wordpress 文章分页方法总结 - WordPress的详细内容...

  阅读:63次