档案页面,而循环不能正常工作 . 特定类别发布了5个帖子 . 但是当我导航到该类别的档案页面时,它只显示3个帖子 .
尝试使用$ count = $ GLOBALS ['wp_query'] - > found_posts显示该特定类别的帖子数量;它返回正确的帖子数(共5个帖子) . 但是当继续执行while循环时,has_posts()只显示3 .
在endwhile之后尝试了wp_reset_query,但没有奏效 . 还尝试使用get_categories()函数显示每个类别中的计数数量,它返回正确的计数,但在while循环中仅显示3个帖子
下面是archive.php代码 .
<div class="row">
<?php
while ( have_posts() ) : the_post();
?>
<div class="col-sm-12 col-md-8">
<div class="blog-post small">
<div class="post-header">
<p class="categories"><a href="#"><?php the_category(', ') ?></a></p>
<h2 class="post-title">
<a href="<? the_permalink();?>"><?php the_title();?></a>
</h2>
<ul class="post-meta">
<li class="date"><?php the_time('F jS, Y') ?></li>
<li class="author">by <a href="<?php the_permalink() ?>"><?php the_author_posts_link(); ?> </a></li>
<li class="comments"><a href="<?php the_permalink() ?>"><?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></a></li>
</ul>
</div>
<div class="post-cover">
<?php
$post_id=get_the_ID();
$meta_info= get_post_meta($post_id, '_thumbnail_id', true );
$image= wp_get_attachment_image_src( $meta_info, $size = 'full', $icon = false );
?>
<a href="<?php the_permalink();?>">
<img width="367" height="346" src="<?php echo $image[0]; ?>" alt="simple post cover" />
</a>
</div>
<div class="post-body">
<p><?php the_excerpt();?></p>
<div class="align-center">
<a href="<?php the_permalink() ?>" class="btn template-btn-2">Read more</a>
</div>
</div>
</div>
</div>
<?php
endwhile;
?>
</div>
我该怎么办 . 任何想法?