wordpress中对长文章添加分页

原来wordpress一直都自带这个功能。只要在 theme目录下面的single.php 中的

<?php the_content(); ?>

修改为:

<?php the_content(); ?>
<?php wp_link_pages(); ?>

然后在文章的编辑窗口中的 “文本” 模式下,再要分页的位置插入

<!--nextpage-->

点击更新,这样既可实现简单的分页功能,只是分页页码的样式不是很好看。

可以研究一下 wp_link_pages()  这个函数,加入不同的html然后在style.css中加入相关的css代码,来写出一个比较不错的样式来,比如这个页面中的样式。

参考地址:http://www.di7zhan.com/237.html/2

实现方法:(方法来自网络,非原创)

一:重新定义分页html

把wp_link_pages()函数替换为下面方法

<?php
     wp_link_pages('before=<div id="fenye">&after=&next_or_number=next&previouspagelink=翻上页&nextpagelink=&nbsp');
     wp_link_pages('before=&after=&next_or_number=number');
     wp_link_pages('before=&after=</div>&next_or_number=next&previouspagelink=&nbsp&nextpagelink=翻下页');
?>

 

css代码为:

#fenye {background: url("image/postnavbg.gif") no-repeat scroll 0 0 transparent;
height:40px;padding:0 10px;
}
#fenye a {
text-decoration: none;
display: inline-block;
margin: 6px 5px;
padding: 0 10px;
background: #65c0ef;
color: white;
line-height: 22px;
-moz-border-radius: 5px;
-khtml-border-radius: 5px;
-webkit-border-radius: 5px 5px 5px 5px;
border-radius: 5px;
}
#fenye a:hover{background: #CCC;}

 

 

 

posted @ 2014-02-12 09:11  张大千  阅读(1662)  评论(0编辑  收藏  举报