php - Pagination in custom loop not working -


i have searched several topics , questions regarding problem, haven´t found answer suits code.

the pagination custom posts displayed, when click in show next posts >> same posts previous page shown, though url shows ?paged=2.

my code following:

<div class="podcast-entries">     <?php     $args = array( 'post_type' => 'strn5_podcasts',                    'posts_per_page' => 3,                    'paged' => (get_query_var('paged') ? get_query_var('paged') : 1 );     $temp = $wp_query;     $wp_query = null;     $wp_query = new wp_query( $args );      if ( $wp_query->have_posts() ) :      while ( $wp_query->have_posts() ) :     $wp_query->the_post();     ?>          <div <?php post_class(); ?> >              <h4 class="podcast-title"><?php the_title(); ?></h4>              <div class="podcast-content">                 <?php the_content(); ?>             </div>              <h6><?php the_time('f j, y'); ?></h6>              <div class="post-separator col-lg-12"></div>          </div>      <?php endwhile; endif; ?>      <div class="navigation-links">          <div class="next-post">             <?php next_posts_link( '>> siguiente entrada' ); ?>         </div>          <div class="previous-post">             <?php previous_posts_link( 'anterior entrada >>' ); ?>         </div>      </div>      <?php $wp_query = null;      $wp_query = $temp;     wp_reset_query(); ?>  </div> <!-- .podcast-entries --> 

usually when doesn't work strip , start rebuilding bare basics see problem might be.

why don't try simpler form of loop see if can prin.t

<?php query_posts(array('posts_per_page' => 3, 'post_type' => 'strn5_podcasts', 'paged' => get_query_var('page'))); if (have_posts()) : while (have_posts()) : the_post(); ?>   <p><?php the_title(); ?></p> <?php endwhile; endif;?>  <div class="navigation-links">   <div class="next-post"><?php next_posts_link( '>> siguiente entrada' ); ?></div>   <div class="previous-post"><?php previous_posts_link( 'anterior entrada >>' ); ?></div> </div> 

it's pretty same thing doing (almost) without variables or other thing "could" go wrong.

edit

in end turned out paged parameter can used paged or page , in case worked out page instead of paged

so ended looking so:

'paged' => get_query_var('page')

on final note, using get_query_var('page') needed if you're using query posts in custom page template you've set homepage.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -