What’s the best way to show just 2 posts in the loop?
<?php
$i = 1;
while (have_posts()):
if ($i == 3)
{
break;
}
the_post();
$i++;
endwhile;
?>
Is there something more “beatiful” ?
What’s the best way to show just 2 posts in the loop?
<?php
$i = 1;
while (have_posts()):
if ($i == 3)
{
break;
}
the_post();
$i++;
endwhile;
?>
Is there something more “beatiful” ?
You must be logged in to post a comment.
Use query_posts():
before the loop.
Excerpt from the documentation page:
Try this:
You can use the WP_Query class, to avoid mixing the globals posts with your custom loop