WordPress Pagination on a Page
One of the goals in redesigning this site was to reduce the amount of emphasis on the weblog – at least on the home page – without losing any standard blog functionality. I also tried to combine the weblog and the full archives on one page in the interest of saving space. I’m not sure how it’ll scale, but it seems to work well enough for now.
The only problem I ran into in pushing the weblog off the front page was in using “pagination” from a “page”. Pagination is easy when your blog is displayed from the home page, but there isn’t any trick built into the query_posts() function to help if you’re trying to display a standard blog from within a page.
After bumbling around for a while, I came across this small bit of code from Kafkaesqui that did the trick:
<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("showposts=5&paged=$page");
while ( have_posts() ) : the_post() ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title() ?></a></h2>
<span class="entry-date"><?php the_time('F d, Y'); ?></span>
<?php the_content(); ?>
<?php endwhile ?>
I’ve added some code in there to complete the_loop as well. I’m sure this will come in handy as people continue to extend WordPress beyond what it was originally intended to do – and I hope this post can save some poor person on Google the headache I’ve got right now :)
Head over to the all new Weblog page to see the results of this endeavor, and make sure to click the “older posts” link at the bottom of the page.