WordPress.org

Ready to get started?Download WordPress

Forums

WP-PageNavi
PageNavi doesn't work at home page !!! (2 posts)

  1. bangnt
    Member
    Posted 2 years ago #

    Dear PageNavi developer,

    I think this plugin has still a problem. It can't paginate at home page.
    This is my home page: http://newreleasemovies.co/
    It still show the pagination, but when clicking in any page, it show the 404 error. For example: http://newreleasemovies.co/page/2/

    Here is my code in the home.php file:

    <?php get_header(); ?>
    		 		<div class="movies-slider">
    					<ul id="mycarousel" class="jcarousel-skin-tango">
    				    <!-- The content will be dynamically loaded in here -->
    				  </ul>
    		 		</div>
    		<div id="movies">
    
    			<section>
    				<header>
    					<h2 class="page-title">
    							<?php _e( 'New Release', 'bqhmovies' ); ?>
    					</h2>
    				</header>
    
    	<?php
    		  $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    		  $wp_query = new WP_Query(array('post_type' => 'movies',
    			'posts_per_page' => '5',
    			'paged' => $paged)
    								   );
    		  while ($wp_query->have_posts()) : $wp_query->the_post();
    			 get_template_part( 'content', 'listmovie' );
    			endwhile;
    
    		// Reset Query		
    
    		 wp_pagenavi( array(
    		  'query' => $wp_query
    		 ));
    		wp_reset_postdata();
    		?>
    				</section>
    		</div><!--/#movies-->
    <?php get_sidebar("movies"); ?>
    <?php get_footer(); ?>

    http://wordpress.org/extend/plugins/wp-pagenavi/

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it without the new WP_Query: http://pastebin.com/ishAFuxg
    And with this in your theme's functions.php:

    function my_post_queries( $query ) {
      // not on admin pages and is the main query
      if (!is_admin() && $query->is_main_query()){
        if(is_home()){
          $query->set('posts_per_page', 5);
          $query->set('post_type', 'movies');
        }
      }
    }
    add_action( 'pre_get_posts', 'my_post_queries' );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic