Run Loop on Posts of Specific Category

Avatar of Chris Coyier
Chris Coyier on
<?php query_posts('cat=5'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
   <?php the_content(); ?>
<?php endwhile; endif; ?>

If you were to use this, for example, in a left sidebar which ran before the main loop on your page, remember to reset the query or it will upset that main loop.

<?php wp_reset_query(); ?>