收录了这篇文章
分页方法一:
the_posts_pagination(array( 'mid_size' => 3, 'prev_text' => '<', 'next_text' => '>', 'screen_reader_text' => ' ', 'aria_label' => "xxx", ));
分页方法二:
$big = 999999999; echo paginate_links(array( 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, $paged), 'total' => $query_posts->max_num_pages, 'mid_size' => 3, 'prev_text' => __('«'), 'next_text' => __('»'), 'type' => 'list' ));
分页方法三:
function custom_pagination( $before = '', $after = '', $p = 3 ) { if ( is_singular() ) return; global $wp_query, $paged; echo '$paged'.$paged; $max_page = $wp_query->max_num_pages; if ( $max_page == 1 ) return; if ( empty( $paged ) ) $paged = 1; echo $before.'<nav id="pagenavi">'."\n"; if ( $paged > 1 ) create_link( $paged - 1, '上页', '上页' ); if ( $paged > $p + 1 ) create_link( 1, '第一页' ); if ( $paged > $p + 2 ) echo '<span class="pages">...</span>'; for( $i = $paged - $p; $i <= $paged + $p; $i++ ) { if ( $i > 0 && $i <= $max_page ) $i == $paged ? print "<span class='page-numbers current'>{$i}</span>" : create_link( $i ); } if ( $paged < $max_page - $p - 1 ) echo '<span class="pages">...</span>'; if ( $paged < $max_page - $p ) create_link( $max_page, '最后一页' ); if ( $paged < $max_page ) create_link( $paged + 1,'下页', '下页' ); echo '</nav>'.$after."\n"; } function create_link( $i, $title = '', $linktype = '' ) { if ( $title == '' ) $title = "第 {$i} 页"; if ( $linktype == '' ) { $linktext = $i; } else { $linktext = $linktype; } echo "<a class='page-numbers' href='", esc_HTML( get_pagenum_link( $i ) ), "' title='{$title}'>{$linktext}</a>"; }
声明:本站所有文章和图片,如无特殊说明,均为原创发布。商业转载请联系作者获得授权,非商业转载请注明出处。