Posts Tagged ‘page

PHP代码 function pagination($query_string){ global $posts_per_page, $paged; $my_query = new WP_Query($query_string ."&posts_per_page=-1"); $total_posts = $my_query->post_count; if(empty($paged))$paged = 1; $prev = $paged - 1; $next = $paged + 1; $range = 3; // only edit this if you want to show more page-links $showitems = ($range * 2)+1; $pages = ceil($total_posts/$posts_per_page); if(1 != $pages){ echo "<div class='pagination'>"; echo "共 ".$pages." 页 "; echo ($paged > ($range+1) && $showitems < $pages)? "<a href='".get_pagenum_link(1)."'>首页</a>":""; echo ($paged > 1 && $showitems < $pages)? "<a href='".get_pagenum_link($prev)."'>上一 ...