wordpress分页函数,不是插件!
functions.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 "<a href='" . get_pagenum_link(1) . "' class='extend' title='跳转到首页'> 返回首页 </a>";} previous_posts_link(' 上一页 '); if($max_page > $range){ if($paged < $range){for($i = 1; $i <= ($range + 1); $i++){echo "<a href='" . get_pagenum_link($i) ."'"; if($i==$paged)echo " class='current'";echo ">$i</a>";}} elseif($paged >= ($max_page - ceil(($range/2)))){ for($i = $max_page - $range; $i <= $max_page; $i++){echo "<a href='" . get_pagenum_link($i) ."'"; if($i==$paged)echo " class='current'";echo ">$i</a>";}} elseif($paged >= $range && $paged < ($max_page - ceil(($range/2)))){ for($i = ($paged - ceil($range/2)); $i <= ($paged + ceil(($range/2))); $i++){echo "<a href='" . get_pagenum_link ($i) ."'";if($i==$paged) echo " class='current'";echo ">$i</a>";}}} else{for($i = 1; $i <= $max_page; $i++){echo "<a href='" . get_pagenum_link($i) ."'"; if($i==$paged)echo " class='current'";echo ">$i</a>";}} next_posts_link(' 下一页 '); if($paged != $max_page){echo "<a href='" . get_pagenum_link($max_page) . "' class='extend' title='跳转到最后一页'> 最后一页 </a>";}} }
css中
/* -----------page nav-------*/ .page_navi{width:100%;height:80px;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;}
在页面中category.php中调用
<div class="page_navi"><?php par_pagenavi(); ?></div>
相关推荐
Wordpress0 2020-09-27
bluehost 2020-09-15
maccarty 2020-08-03
86520993 2020-07-28
WordPress 2020-07-04
李维山 2020-06-21
GimmeS 2020-06-14
WordPress 2020-06-10
shayuchaor 2020-06-10
liwf 2020-06-02
疯狂老司机 2020-05-26
zcl 2020-05-12
timewind 2020-05-11
86520993 2020-05-04
Lophole 2020-04-29
fraternityjava 2020-04-23
84911835 2020-04-16
maccarty 2020-04-09
WordPress 2020-04-07