I have customized my WordPress home page. Few days ago i found that the next and previous page links are not working properly i try to solve it and finally found a solution on wordpress website. To solve wordpress page links problem read below:
When we use query_post() to exclude or include some posts of specific categories then the pagination of wordperss doesn’t work. It will show same posts on every page as home page.
The problem is query_posts() function overrides nearly everything in the standard posts object query, including paged offset is.
For proper pagination with query_posts(). Use the following code:
Existing Code: <?php if(have_posts()) : ?> <?php query_posts("category_name=CategoryName"); ?> <?php while(have_posts()) : the_post(); ?> Replace With: <?php if(have_posts()) : ?> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=CategoryName&paged=$paged"); ?> <?php while(have_posts()) : the_post(); ?>
You are done!
Instead of using query_post() functionTheir is another solution to exclude or include posts of different categories from wordpress home, archive of other pages you can use “Advance Category Excluder” plugin of wordpress. Its very simple and easy to use plugin to perform such tasks.