Paginate a list of post titles on a page
-
This is probably a very simple fix, but I’m tearing my hair out at this point and need a boot in the right direction.
I have a page called “Memos” that I am using to display an unordered list of all posts with the category “memos”. This is going to be an archive of all Memos that are written in my company, with a new post being added for each memo. As you can imagine, this is going to be a VERY long list.
I’d like to implement pagination on this list and limit it to 20-30 items per page, but as I built ‘the loop’ from scratch on the page.php, I’m not sure how to get paging to work. I have done some searching and have come across several fairly helpful entries here on the support forums, but I must be missing something because its not working. Not sure if I need
Here is the code I have so far in page.php…
<div class="fl span-12"> <?php if (have_posts()) : ?> <?php $catID = 0; if (is_page('memos')){ $catID=5; } if ($catID) : $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("posts_per_page=20&category_name=memos&page=$page");?> <!-- The following HTML structure is necessary to keep the styling of the 'Memos' page consist with the other pages --> <ul class="list-3 block"> <li class="i"> <div class="clear"> <div class="pagebody"> <div class="pagetitle">Memos</div> <div class="pagecontent"> <ul> <?php while (have_posts()) : the_post(); ?> <li> <?php the_content('Read the rest of this entry »'); ?> </li> <?php endwhile; ?> </ul> </div> </div> </div> </li> </ul> <?php else : ?> <ul class="list-3 block"> <?php while (have_posts()) : the_post(); ?> <li class="i"> <div class="title-0"> </div> <div class="clear"> <?php the_content('Read the rest of this entry »'); ?> </div> </li> <?php endwhile; ?> </ul> <?php endif; ?> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> </div>
Notice that I have not defined any ‘next’ or ‘previous’ buttons or links. Out of everything that I have found, none of them mentioned needing them and many discussed WP’s “out of the box” pagination ability, so I am assuming WP will create that automatically if I can get the code correct.
Any and all help in this is greatly appreciated.
Thanks
- The topic ‘Paginate a list of post titles on a page’ is closed to new replies.