wp-pagenavi getting 404 page not found

WordPress WP-PageNavi plugin gettinf 404 error. here is my code.

 <?php  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

   query_posts(array(
    'posts_per_page' => 3,
    'paged' => $paged
   )
  ); ?>
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>

<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php the_title('<h1 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a></h1>'); ?>

 <?php endwhile;  if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>

   <?php wp_reset_query(); else : ?>

<p class="no-posts"><?php _e('Sorry, no posts matched your criteria', 'example');  </p>

  <? php endif; ?>  

Related posts

1 comment

  1. Maybe you missed the object here, and by the way why do you use query_posts() ? You can try this :

    <?php  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
     $args = array(
       'posts_per_page' => 3,
       'paged' => $paged
    ); 
    
    $query = new WP_Query($args);
    if($query->have_posts()) : while($query->have_posts()) : $query->the_post(); ?>
    
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    <?php the_title('<h1 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute('echo=0') . '" rel="bookmark">', '</a></h1>'); ?>
    
    <?php endwhile;  if(function_exists('wp_pagenavi')) { wp_pagenavi($query); } ?>
    

Comments are closed.