Support » Fixing WordPress » Next Post/Previous Post Problem

  • Resolved thsoto


    I have the following code on my home page.

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>

    <span class=”title”>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?></span>
    <span class=”date”><?php the_time(‘F jS, Y’) ?></span>
    <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?>

    <?php endwhile; ?>
    <div class=”navigation”>
    <div class=”alignleft”><?php next_posts(‘« Older Articles’) ?></div>
    <div class=”alignright”><?php previous_posts(‘Newer Articles »’) ?></div>
    <?php else : ?>
    <h2 class=”center”>Not Found</h2>
    <p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
    <?php get_search_form(); ?>

    <?php endif; ?>

    It is not showing the links for Next and Previous Articles. All it shows is my web address.

    Can someone tell me what I have done wrong?


Viewing 5 replies - 1 through 5 (of 5 total)
  • next_posts_link and previous_posts_link will work fine with label.

    <div class="alignleft"><?php next_posts_link('« Older Articles') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Articles »') ?></div>

    Thanks! I originally had that and it was showing up. Just tried it again and it works. The only thing I changed was in the Settings > Reading section I changed the Blog posts to 1 instead of the default of 10. Apparently, that’s why it wasn’t showing up.

    Having the same problem on my single.php page.

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div id="textwrap"><h1><?php the_title(); ?></h1>
    			<div id="textarea">
    				<span class="date"><?php the_time('F jS, Y') ?></span><br />
    				<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    					<div class="entry">
    						<?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
    						<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    						<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
    		<?php //comments_template(); ?>
    		<?php endwhile; ?>
    				<div class="navigation">
    					<div class="alignleft"><?php next_posts_link('&laquo; Older Articles') ?></div>
    					<div class="alignright"><?php previous_posts_link('Newer Articles &raquo;') ?></div>
    		<?php else: ?>
    			<p>Sorry, no posts matched your criteria.</p>
    	<?php endif; ?>

    Why won’t it display on these?


    In single.php use next_post_link and previous_post_link

    next_post_link(‘%link’, ‘« Older Articles’)
    previous_post_link(‘%link’, ‘Newer Articles »’)

    Thanks! That worked!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Next Post/Previous Post Problem’ is closed to new replies.