I'm using the "A page of posts" to crate a sort of blog page.
My question is how do I limit the number of posts, but also allow navigation to the next oldest posts.
I am easily able to limit the number of posts, but I have not figured out how to add "Next Page" / "Previous Page" links.
below is the code:
<?php
// page id 21 will get category ID 12 posts, page 16 will get category 32 posts, page 28 will get category 17 posts
if (is_page('76') ) {
$cat = array(4);
} elseif ( is_page('16') ) {
$cat = array(32);
} elseif ( is_page('28') ) {
$cat = array(4);
} else {
$cat = '';
}
$showposts = -1; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => $cat,
'showposts' => $showposts,
'caller_get_posts' => $do_not_show_stickies
);
$my_query = new WP_Query($args);
?>
<?php if( $my_query->have_posts() ) : ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
//necessary to show the tags
global $wp_query;
$wp_query->in_the_loop = true;
?>
<div class="entry">
<?php the_content('Read the rest of this entry ยป'); ?>
</div>
<p class="postmetadata"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?> | </a> Posted <?php the_time('F jS, Y') ?> | Category "<?php the_category(', ') ?>" <?php edit_post_link('| Edit','',''); ?> </p>
<?php endwhile; ?>
<?php posts_nav_link(); ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>
<?php endif; ?>