May 11, 2009

Add "previous page" to your Wordpress theme

 
If you use some Wordpress theme that doesn't have "previous entries", "old entries" or "previous page" in the footer of your blog then there is a really easy way to tweak this and add this functionality.
 

I use great Rhianna theme on my blog I love it but I found that this missing feature isn't user friendly. What you need it to edit your index.php file from your theme and add few lines near the end of the file.
 

<div class="navigation"> <div class="alignleft"> < ?php next_posts_link('&larr; Previous Entries') ?> </div> <div class="alignright"> < ?php previous_posts_link('Next Entries &rarr;') ?> </div> </div>

Just add previous lines before this line:
< ?php get_sidebar(); ?>
 
So that end of your index.php looks like this:

<div class="navigation"> <div class="alignleft"> < ?php next_posts_link('&larr; Previous Entries') ?> </div> <div class="alignright"> < ?php previous_posts_link('Next Entries &rarr;') ?> </div> </div>

< ?php get_sidebar(); ?>

< ?php get_footer(); ?>

  NOTICE: Please note that because of modsecurity apache security plugin on this blog I have some restrictions, so in order for this code to work you need to delete spaces between < and ? in lines that have ?php in them.