I've created custom page templates showing the posts for different categories on each page, and would like to limit the number of posts per page to 6.
I've added query_posts('categoryname=news&posts_per_page=6'); to the page and it displays the correct category and limits it to 6 posts, however when I go to page/2 it displays the same 6 posts and so on.
How do I get it to show the next 6 posts as I wish?
Any help appreciated.
Example of proper pagination and corrected category_name:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('category_name=news&posts_per_page=6&paged=' . $paged);
?>
nickbudden
Member
Posted 3 years ago #
Is this code supposed to go into the header? I've tried it in a category template I've made, as I'm having the same problem, but the problem has continued.
Typically that goes in a category template.
nickbudden
Member
Posted 3 years ago #
Thank you, I think I'd put it in the wrong place because now it is working. Thanks again.
nickbudden
Member
Posted 3 years ago #
Sorry, but is it possible to have a different number of posts for the first page in the category, and a different number for all other pages in that category?
I thought I remember seeing someone with a solution for that question but I can't find it...it was in the forums I'm pretty sure.