Support » Themes and Templates » previous_post_link(); and next_post_link(); Not Working

  • Hi –

    I’ve looked through the forums and all the examples I see for using the previous_post_link(); and next_post_link(); don’t seem to work for my page template.

    Some background

    I have set up a category called “news” (cat_id=5). In this category are a series of posts (17 in all). I’d like to show the first 10 within the page template, then have simple previous/next links at the bottom of the page that links to the remaining 7 posts. I’ve confirmed that I’ve created a page and assigned it to the template code below:

    Template Name: Template G - News Listing Page
    <?php get_header(); ?>
    <div id="content" class="<?php the_title(); ?> widecolumn">
      $newsposts = get_posts('category_name=news&numberposts=10&order=DESC'); /* restrict category, show max 10 posts and order DESC */
      foreach($newsposts as $post) :
      <h2><?php the_date(); ?></h2>
      <h3><a><"div id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h3>
      <?php the_content(); ?>
      <?php previous_post_link(); ?> <?php next_post_link(); ?>
      <?php endforeach; ?>  
    <?php get_footer(); ?>
    <em>Template G - News Listing Page</em>

    The news page renders just fine and spits out the first 10 posts in question, but for some reason the pagination’s HTML is not rendered and no errors are thrown. Any suggestions?

    Thanks in advance,


Viewing 1 replies (of 1 total)
  • I’m doing something similar. It appears the next_post_link and previous_post_link are specific for posts and not pages.

    Did you ever whip up a custom solution or find one? If not, I guess I could write out the function. It shouldn’t be difficult.


Viewing 1 replies (of 1 total)
  • The topic ‘previous_post_link(); and next_post_link(); Not Working’ is closed to new replies.