WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is my loop

        $my_query = new WP_Query(array(
                'cat' => -399,
                'posts_per_page' => 6,
                'offset' => 5,
                'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
        ));
        if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post(); 
            $imgurl = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
            $finalurl = get_stylesheet_directory_uri(). "/functions/thumb.php?w=180&h=180&a=t&src=".$imgurl;
            $date = get_the_date(); 
            $id = $post->ID;
        ?>
        .... loop contents ....

        <?php $finalurl = "";
        endwhile;
        else: ?>
        <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
        <?php endif; wp_reset_query();
        $id = ""; wp_pagenavi();

Pagination shows same content in all pages. I need your suggestion.

share|improve this question
up vote 2 down vote accepted

Try changing $my_query to $wp_query to see if that fixes the issue. I found that when you rename the query it messes with the pagination.

Also you should move the reset query after the pagination. Here's a loop I've verified works with pagination:

$args = array(
    'posts_per_page' => 10,
    'post_type'      => 'post',
    'paged'          => get_query_var( 'paged' ),
);
$wp_query = new WP_Query( $args );
while ( $wp_query->have_posts() ) : $wp_query->the_post();
    get_template_part( 'templates/content', 'posts' );
endwhile;

/*
  PAGINATION
*/
if ( function_exists( 'page_navi' ) ) {
    ?>

    <div id="pagination">
        <?php page_navi(); ?>
    </div>
<?php }
wp_reset_query(); ?>
share|improve this answer
    
Worked, thanks. – Enthusiast Feb 7 '14 at 7:46

if you use wp_pagenavi in front page, yes, it won't work. you need to change the current paged in wp_pagenavi function like this:

// I changed the code below, you can see what different from yours.

if(!empty($paged)) {
    $paged = $paged;
}elseif(get_query_var( 'paged')) {
    $paged = get_query_var('paged');
}elseif(get_query_var( 'page')) {
    $paged = get_query_var('page');
}else {
    $paged = 1;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.