Forums

How do I install pagination on the front page? (4 posts)

  1. cscott5288
    Member
    Posted 2 years ago #

    Okay, so I have been working on a theme for my blog for quite a while now.
    One of the last things I need to do is have a pagination feature at the bottom of the front page. Here is the site: http://www.hospiceinform.net/

    What php code is recommended for this? My front page retrieves posts a little differently than others. Here is the code for the front page:

    http://pastebin.com/HqjNNmWu

    The code was given to me by someone on the forum so I don't know exactly how it works.

    Appreciate any help/advice.

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    that is a totally normal loop; which makes it easy.

    after this line:

    <?php endwhile; ?>

    insert something like this (that is a copy from the pagination of the default theme):

    <div class="navigation">
    	<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    	<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>

    change or remove the formatting divs if you like.

    details:
    http://codex.wordpress.org/Template_Tags/next_posts_link
    http://codex.wordpress.org/Template_Tags/previous_posts_link

    or use 'posts_nav_link' instead:
    http://codex.wordpress.org/Template_Tags/posts_nav_link

  3. cscott5288
    Member
    Posted 2 years ago #

    This works great, but is there any way I can easily do a list of pages going back like what I have on the free template I am using: http://www.blogtap.net/

    Thanks a million for your help!

  4. alchymyth
    The Sweeper
    Posted 2 years ago #

    use a plugin such as wp-pagenavi
    http://wordpress.org/extend/plugins/wp-pagenavi/

    usage for instance:

    <?php if(function_exists('wp_pagenavi')) wp_pagenavi(); else { ?>	
    
    <div class="pagenav"><?php posts_nav_link(' — ', __('&laquo; Previous Page of Articles'), __('Next Page of Articles &raquo;')); ?></div>
    <?php } ?>

    this would check if the plugin is activated, or otherwise use your 'handmade' pagination.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.