I wish to develop a loop in which the first 2 posts of category 8 are proven on page one and also to display pagination underneath the loop, therefore if you will find more posts the customer can navigate for them with "next page" "previous page" links.
I personally use
<?php posts_nav_link(); ?>
for pagination but thera aren't any links proven. I believe maybe I ought to consider adding the parameter 'paged' to my loop, however , I'm not sure how to get this done. Any help could be greatly appreciated!
<?php $args = array( 'numberposts' => 2, 'category' => 8 ); $lastposts = get_posts( $args ); foreach($lastposts as $post) : setup_postdata($post); ?> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <?php the_excerpt(20); ?> <div id="pagenav"> <?php posts_nav_link(); ?> </div> <?php endforeach; ?>
In my opinion the next code should come following the endforeach.
<div id="pagenav"> <?php posts_nav_link(); ?> </div>