text:
Tobias Groganz
tags:
wordpress
Lately I found myself faced with the problem that I wanted to add a certain pagination to the blog-post page of my homepage. The query of the page was a custom query in order to select only posts categorized as a blog post. After adding the pagination template tags to the site, the problem was that on each page the same blog posts as on my first page appeared. I searched on the Internet quiet a long time but I did not find any proper solution. In the end I found the answer deep down in the wordpress documentation. In case you are experiencing the same problem as me, try this:
My query used to be:
<?php query_posts(‘category_name=blog-entry &orderby=date&order=DESC’); ?>
What helped for me solving this problem was exchanging the above code by this:
<?php query_posts( array( ‘cat’ => 5, ‘paged’ => get_query_var(‘paged’) ) ); ?>
Note that you have to put in the right category number. The statement didn’t work for me.
Just to get the whole case complete, these are the pagination tags:
<?php previous_posts_link(‘<< Newer Entries’); ?>
<?php next_posts_link(‘Older Entries >>’); ?>
