Solved issue with query_posts and pagination

Issue with query_posts and pagination

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(); ?>

Solved issue with query_posts and pagination
Solved issue with query_posts and pagination

Useful article for query post

http://codex.wordpress.org/Template_Tags/query_posts

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.