Reputation: 536
I tried to use wordpress function query_posts('showposts=3&cat=1') to display the latest posts under category 1. But it displays 4 or 5 posts. Could you please help figure out the root cause? Thanks.
<?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; ?>
Upvotes: 0
Views: 4547
Reputation: 259
You need to start the loop after you define the query_posts().
So the code becomes:
<?php query_posts('showposts=3&cat=17');
while (have_posts()) : the_post(); ?>
<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; ?>
Upvotes: 2