WordPress.org

Ready to get started?Download WordPress

Forums

Paginate a list of post titles on a page (7 posts)

  1. bblanton73
    Member
    Posted 4 years ago #

    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 &raquo;'); ?>
    					</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 &raquo;'); ?>
    		        </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

  2. Jonas Grumby
    Member
    Posted 4 years ago #

    The Swift theme has very nice pagination buttons at the bottom of archive pages. Download the theme and see if you can figure out how they did it.

    Also see if this helps:

    http://codex.wordpress.org/Styling_Page-Links

  3. bblanton73
    Member
    Posted 4 years ago #

    Ok, according to that link, I'm assuming that I need to use wp_link_pages(), but I'm not sure where to throw it in.

  4. manowar3
    Member
    Posted 4 years ago #

    bblanton73, did you fix the problem?
    I'm facing a similar problem and failed to solve it yet.

  5. vtxyzzy
    Member
    Posted 4 years ago #

    This article on Paging and Custom Loops might help.

  6. manowar3
    Member
    Posted 4 years ago #

    thanks vtxyzzy! that did the trick :)

  7. vtxyzzy
    Member
    Posted 4 years ago #

    @bblanton73, did that help you?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags