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.
HOLY SHIT! THANK YOU SOOOOO MUCH! I have been trying to get this working for so long. I owe you one.
WordPress Pagination Plugin For SEO…
How well are your older posts being crawled by search engines?
If your blog contains hundreds or thousands of posts you could be in DEEP trouble.
Pagination will place your older posts deeper and deeper in your directory. Several layers or several doze…
C O N G R A T U L A T I O N S for these two lines of code – a elegant respond to adapt special category webpage without using the default showposts set in options admin page.
Many than again !
wow, thanks for that! i’ve been looking around for something like that and it worked like a charm!
[...] search the web a little bit and found this. So, I headed over to my theme designer and added the following code inside the <title> [...]
I use this little line almost in all of my work!
Thank you for posting this – perfectly solved my problem!
Love the website/blog, btw. It’s beautiful clean and easy to read. Love it.
Thanks! Been searching for how to do this for over an hour now.
Thank you VERY MUCH!!!
I also was having problems with this.
Thanx for sharing!
Thank god, you just saved my life.
Thanks a ton! you save my time.
Heyy Buddy… This is real cool :) I wish i would have found this blog a day ago…
Hats Off :)
WOW!! Thanks, this is exactly what I need, and it works perfectly. So simple, and so powerful =)
Very impressive, thank you Trevor, you saved my time. I love this blog. Thanks again.
This is exactly what I was looking for. Thank you so much!
gracias por el codigo
excelent great thanks for the help
cheers
Thanks! Badly needed this.
Yeah!! My problem was solved too! Thank you!
Thanks! Worked like a charm :)
You are my hero.
DUDE – I have seriously been searching all day for this. If you we’re in Denver I would buy you beer. Thanks for this!!!!!
You win the internet.
Thanks a ton, have searched high and low for this solution to no avail. Works beautifully :-)