【发布时间】:2019-11-08 07:22:40
【问题描述】:
我尝试使用 wordpress 函数 query_posts('showposts=3&cat=1') 显示类别 1 下的最新帖子。但它显示 4 或 5 个帖子。你能帮忙找出根本原因吗?谢谢。
<?php query_posts('showposts=3&cat=17');?>
<div class="n-placement n-widget w-image-text" data-type="image-text" id="u-aabm">
<div class="n-inner" id="u-aabm-i">
<div class="w-image-text-container">
<span class="w-image-text-image" style="float: left; clear: left; margin-top: 6px; margin-bottom: 6px; margin-right: 6px;">
<img src="<?php echo catch_that_image();?>" height="112" width="112"/>
</span>
<div class="w-image-text-text">
<b>
<!--<a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>-->
<?php the_title(); ?>
</b>
<div>
<div>
<?php
if(is_category() || is_archive() || is_home() ) {
the_excerpt();
} else {
the_content('Read the rest of this entry »');
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php endwhile; ?>
【问题讨论】:
-
你试过这个 query_posts('posts_per_page=3');
-
Hi Sismater,我刚才试过了,但是没用。
-
您是否在执行查询之前重置了查询?
-
你在哪里开
while? -
你没有循环 - codex.wordpress.org/The_Loop