I’m trying to create a paginated blog in WordPress, displaying only posts in a certain category (2). I’m trying to piece together example code from other sites, but can’t make the blog simultaneously paginated and just display posts in category 2.
My code is:
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=2&paged=$paged");
foreach($posts as $post):
<div id="blog">
<?php the_title(); ?>
<?php endforeach; ?>
</div>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
Can anyone help?