admin管理员组文章数量:1317915
This my code for sub category archive page:
<?php
// the query
$the_query = new WP_Query(array(
'category__and' => array( 2 ),
'post_status' => 'publish',
'post_type' => 'post',
'posts_per_page' => 12,
'paged' => get_query_var( 'paged' ),
));
?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
//Contents Here//
<?php endwhile; ?><?php wp_reset_postdata(); ?><?php endif; ?>
And this is my pagination code:
<?php global $wp_query; if ($wp_query->max_num_pages > 1) : ?>
<div class="col-xl-12 col-lg-12 col-md-12">
<div class="mt-40 mb-60">
<?php mytheme_pagination(); ?>
</div>
</div>
<?php endif; ?>
EDIT: Here is mytheme_pagination code:
function mytheme_pagination() {
global $wp_query;
if ( $wp_query->max_num_pages <= 1 ) return;
$big = 999999999; // need an unlikely integer
$pages = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'type' => 'array',
'prev_text' => __( '<i class="flaticon-left-arrow"></i>', 'mytheme' ),
'next_text' => __( '<i class="flaticon-right-arrow"></i>', 'mytheme' ),
) );
if( is_array( $pages ) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '<div class="pagination-wrap"><ul class="pagination">';
foreach ( $pages as $page ) {
echo "<li>$page</li>";
}
echo '</ul></div>';
}
}
Now I have 1 empty extra page number in pagination of my archive page.
For example I have only 3 pages of contents by I can See a number 4 link in pagination numbers who open's an empty page without any posts in there.
PS: There is not any problem with Category Archive page and it's only appears in SUB-Category archive page.
Can you help me please?
本文标签: wp queryWordPress Sub Category ArchiveShow Extra Empty Page Number in Pagination
版权声明:本文标题:wp query - WordPress Sub Category Archive, Show Extra Empty Page Number in Pagination 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742008404a2412425.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论