2023-05-12 开启多语言插件支持……

wordpress分页代码

wordpress 苏 demo 2718℃ 0评论

20140809094414
打开wordpress的funtions.php文件

//分页  
function par_pagenavi($range = 9){   
if ( is_singular() ) return;  
global $wp_query, $paged;  
$max_page = $wp_query->max_num_pages;  
if ( $max_page == 1 ) return;  
if ( emptyempty( $paged ) ) $paged = 1;  
echo ''.第 . $paged .页 .(共 . $max_page .页). '  ';  
    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 " NO.1 ";}    
    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 " END ";}}    
}  

主题的style.css文件里添加样式

/*pagenavi*/  
.page_navi{width:100%;height: 34px;line-height: 34px;text-align:center;overflow:hidden;padding-top: 10px;position:relative;background: #F4F4F4;border-top: 1px solid #E8E8E8;}    
.page_navi a{display: inline-block;margin-right: 8px;height: 24px;line-height:24px;padding:0 8px;background:#e4e5e1;color: #626262;font-size:14px;}  
.page_navi a:hover,.page_navi .current{color:#fff;background: #8c9fcc url(jb.png) no-repeat center top;text-decoration: none;}  
.page_navi .page-numbers{position: absolute;top: 5px;left: 15px;letter-spacing: 1px;font-family: 微软雅黑;color: #424242;}  

添加调用代码至主题index.php、archive.php、category.php、search.php:


打赏

转载请注明:苏demo的别样人生 » wordpress分页代码

   如果本篇文章对您有帮助,欢迎向博主进行赞助,赞助时请写上您的用户名。
支付宝直接捐助帐号oracle_lee@qq.com 感谢支持!
喜欢 (0)or分享 (0)