• Resolved myladeybugg

    (@myladeybugg)


    I am trying to get pagination to work with query_posts, but when I click “more”, page 2 brings up the same articles.

    Here is the code I am working with:

    <?php
    
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    query_posts('posts_per_page=10&orderby=asc&cat=66,1,71&paged=' . $paged);
     //query_posts('posts_per_page=10&orderby=asc&cat=66,1,71');
    if (have_posts()) : 
    
    	while (have_posts()) : the_post(); 
    
    		echo "<div class='home-article ccsClearfix'>";
    
    		echo "<a class='headline' href='".get_permalink()."'><h2 class='home-article-title'>".get_the_title()."</h2>";
    		echo "" .the_post_thumbnail('articles', array('class' => 'alignleft')) ;
    
    		echo "</a><p class='date'>by <a href='".esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) ."'>". get_the_author(). "</a> in ".get_the_category_list( ', ' )."</p>";
    
    		echo "<p>".the_excerpt()."</p>";
    		echo "</div>";
    	endwhile;
    	?>
    
      <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
    <?php
    endif;
    wp_reset_query();
    	?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • If you are coding for a static front page, you need to change this:

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

    to this:

    if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
    elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
    else { $paged = 1; }
    Thread Starter myladeybugg

    (@myladeybugg)

    That worked perfectly, thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘query_posts pagination’ is closed to new replies.