If you are using query_posts in your theme for category and you are facing issue with pagination. usage of query_posts
, leave the original query on the home page intact, and modify the query from your functions.php
file, using pre_get_posts
Solved issue with query_posts and pagination
we solved Issue with query_posts and pagination. If you are using query_posts in your theme and you are facing issue with pagination. for altering any query
Use following code to fix the issue with pagination.
php
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
$sticky=get_option(‘sticky_posts’);
$args=array(
‘cat’=>3,
‘caller_get_posts’=>1,
‘post__not_in’ => $sticky,
‘paged’=>$paged,
);
query_posts($args);
?>
or use following code.
php if (have_posts()) : ?>
php query_posts(“cat=3”); ?>
php while (have_posts()) : the_post(); ?>
replace with above with this code.
php if (have_posts()) : ?>
php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts(“cat=3&paged=$paged”); ?>
<?php while (have_posts()) : the_post(); ?>
Useful article for query post