0

I am having a problem with my blog page archive.php. When I click the next link at the bottom navigation there are no more posts.

I have a pretty basic setup which works fine for my search.php, the only real difference being the featured section, what am I doing wrong?

archive.php:

<?php get_header(); ?>

<div id="content">
  <div class="content-inner">
    <div class="content-two content-blog">
      <div class="content-cell">
        <h3 class="blog-heading">Blog</h3>
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>

        <div class="entry">
          <h3 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
          <div class="entry-details">
            <span class="entry-author"><?php the_author_link(); ?></span>
            <span class="entry-date"><?php the_time('M j, Y') ?></span>
          </div>
          <hr/>
          <div class="entry-content">
            <?php the_content(); ?>
          </div>
        </div>

        <?php endwhile; ?>

        <?php 
          $prev_link = get_previous_posts_link(__('<span class="page-prev"><i class="material-icons">&#xE314;</i>Prev</span>'));
          $next_link = get_next_posts_link(__('<span class="page-next">Next<i class="material-icons">&#xE409;</i></span>'));
          if ($prev_link || $next_link) : ?>

        <div class="navigation"><p>

        <?php
          if ($prev_link){
            echo $prev_link;
          } else {
            echo '<span class="page-prev"><i class="material-icons">&#xE314;</i>Prev</span>';
          }
          echo ' - ';
          if ($next_link){
            echo $next_link;
          } else {
            echo '<span class="page-next">Next<i class="material-icons">&#xE409;</i></span>';
          } 
        ?>

        </p></div>

        <?php endif; ?>
        <?php endif; ?>

      </div>
      <div class="content-cell featured-cell">

      <h3 class="featured-heading">Featured Posts</h3>
      <?php query_posts( array( 
        'post_type' => 'post',
        'posts_per_page' => -1 ) 
        ); 
      ?>
      <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <?php if ( has_post_thumbnail() ) : ?>
          <div class="feature">
            <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
              <?php the_post_thumbnail('thumbnail'); ?>
              <span class="featured-title"><?php the_title(); ?></span>
            </a>
          </div>
        <?php endif; ?>
      <?php endwhile; ?>

      <?php wp_reset_query(); ?> 

      </div>


    </div><!-- End of .content-two-->
  </div><!-- End of .content-inner--> 

</div><!-- End of #content-->

<?php get_footer(); ?>
9
  • I tested the code posted, and pagination worked for me. How many posts do you have, and how many posts are configured to display on each page under Settings > Reading > Blog pages show at most? Oct 15, 2016 at 23:17
  • Reading settings are at default 10. I made 11 dummy posts to test it but the 11th post doesn't seem to show on the next page. I will go and test again to double check...
    – user500665
    Oct 15, 2016 at 23:42
  • @DaveRomsey I have double checked and page1 stops at 10 posts then page 2 never has any. Also see last comment I forgot to @ you.
    – user500665
    Oct 16, 2016 at 21:50
  • Hrmm, I double checked too, and pagination is definitely working. Have you disabled all plugins? Which archive are you viewing (tags,categories,date,author)? Oct 16, 2016 at 21:56
  • @DaveRomsey There are no plugins on this particular area of the site. It is just the main all posts listing. I am new to Wordpress so maybe I am doing something fundamentally wrong? Is archive.php the right template to use?
    – user500665
    Oct 16, 2016 at 22:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.