How to get the list of posts in a static page other than front page?

The way I retrieve posts on my blog is to use the following:

<?php $recentPosts = new WP_Query(); $recentPosts->query('showposts=5&cat=CAT_ID_GOES_HERE'); while($recentPosts->have_posts()): $recentPosts->the_post(); ?>

Then you would go and create the code to control the display of each post. So for a really simple example:

<h1 class="title"><a href="https://wordpress.stackexchange.com/questions/3170/<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>

Then at the end of the posts you just have to end your while loop:

<?php endwhile; ?>

Leave a Comment