这个文件在你的模板目录下,如果寻找模板目录请参考
wordpress模板修改及函数说明
一、添加功能代码至 functions.php(的php循环内)
function par_pagenavi($range = 9){
global $paged, $wp_query;
if ( !$max_page ) {$max_page = $wp_query->max_num_pages;}
if($max_page > 1){if(!$paged){$paged = 1;}
if($paged != 1){echo " 首页 ";}
previous_posts_link(' 上一页 ');
if($max_page > $range){
if($paged < $range){for($i = 1; $i <= ($range + 1); $i++){echo "$i";}}
elseif($paged >= ($max_page - ceil(($range/2)))){
for($i = $max_page - $range; $i <= $max_page; $i++){echo "$i";}}
elseif($paged >= $range && $paged < ($max_page - ceil(($range/2)))){
for($i = ($paged - ceil($range/2)); $i <= ($paged + ceil(($range/2))); $i++){echo "$i";}}}
else{for($i = 1; $i <= $max_page; $i++){echo "$i";}}
next_posts_link(' 下一页 ');
if($paged != $max_page){echo " 最后一页 ";}}
}
二、添加美化代码至主题style.css
.page_navi{width:100%;height:36px;line-height:36px;text-align:center;overflow:hidden;padding-top:1em;}
.page_navi a{padding:3px 8px;margin:2px;text-decoration:none;color:#888;border:1px solid #ccf;}
.page_navi a:hover,.page_navi a.current{border:1px solid #356aa0;color:#356aa0;font-weight:bolder;}
三、添加调用代码至主题index.php、archive.php、category.php、search.php
OK,大功造成!又可以干掉一个已为数不多的插件咯!
http://immmmm.com/wordpress-page-navigation-without-plugins.html
You must be logged in to post a comment.
[…] 月小升软件 ← wordpress无插件实现列表分页 […]