Support » Fixing WordPress » Need a 'more posts' / 'next posts' link on homepage

  • On our site’s homepage, we have 10 of our recent posts displaying. However, after the list of 10 recent posts, it’s been requested to have a ‘see more posts’ / ‘next posts’ link so that, when clicked, takes the user to a page (or, actually, pages that are paginated) with all posts–like a category archive-type page.

    I’ve tried several things, such as including this to the end of our code:

    <?php posts_nav_link(); ?>

    and

    <?php next_posts_link('More Articles »','') ?>

    But all I get doing that (or variations thereof that I found), is a “Next Page »” link that goes to /page/2/. The problem here is when clicked, the same homepage appears, but the URL in the address bar shows our-site.com/page/2/, so the next set of posts aren’t displayed on the page.

    What do I need to do to add a link to take the user to some sort of an archive-type page which displays all posts–and preferably starting on that page with the 11th most recent post?

    Here’s the code that we have on the index.php template to display the 10 most recent posts:

    <div id="content-secondary" class="clearfix">
      <?php $commentImage =	'<img src="' .
    													get_bloginfo('template_directory') .
    													'/images/comments-bubble.gif' .
    													'" alt="comments: " />'; ?>
      <?php $loop2_posts = new WP_Query("showposts=15&offset=1&cat=-14,-15"); /* second loop */  ?>
      <?php if($loop2_posts->have_posts()) : ?>
      <?php while($loop2_posts->have_posts()) : $loop2_posts->the_post(); ?>
      <div class="post clearfix" id="post-<?php the_ID(); ?>">
        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
          <?php the_title(); ?>
          </a></h2>
        <?php if (get_post_meta($post->ID, "image", $single = true)) : ?>
        <p class="associatedImage"> <img alt="<?php the_title_attribute(); ?>" src="<?php echo bloginfo('template_url'); ?>/thumb.php?src=<?php echo get_post_meta($post->ID, "image", $single = true); ?>&w=64&h=48&zc=1&q=80" /> </p>
        <?php else : ?>
        <!-- no pic -->
        <?php endif; ?>
        <div class="entry">
          <?php the_excerpt(); ?>
          <span class="commentsCount">
          <?php comments_popup_link('', $commentImage.'1', $commentImage.'%'); ?>
          </span> </div>
      </div>
      <?php endwhile; ?>
      <?php else : ?>
      <h2 class="center">Not Found</h2>
      <p class="center">Sorry, but you are looking for something that isn't here.</p>
      <?php include (TEMPLATEPATH . "/searchform.php"); ?>
      <?php endif; /* /second loop */ ?>
      <?php unset($loop2_posts); ?>
    
    <?php next_posts_link('More Articles &raquo;','') ?>
    
    </div>
    <!-- #content-secondary -->
  • The topic ‘Need a 'more posts' / 'next posts' link on homepage’ is closed to new replies.