Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Kevin Esther
8,551 PointsPrevious and Next links not showing wordpress
Ok probably been staring at code to long. Expect that may be something really stupid that am just not noticing.
After install disqus comments the previous and next disappear on single.php.
Need other pair of eyes
wordpress code.
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<section class="l-constrained_blog">
<article>
<header class="post_header">
<h2 id="fittext2" class="title_post"><?php the_title(); ?></h2>
<time datetime="<?php the_time( 'Y-m-d' ); ?>" pubdate><?php the_date(); ?> <?php the_time(); ?></time> <?php comments_popup_link('Leave a Comment', '1 Comment', '% Comments'); ?>
</header>
<?php the_content(); ?>
<div class="pre_nx">
<div class="nav_previous"><?php next_posts_link('Previous'); ?> </div>
<div class="nav_next"><?php previous_posts_link('Next'); ?></div>
</div>
<?php if ( get_the_author_meta( 'description' ) ) : ?>
<?php echo get_avatar( get_the_author_meta( 'user_email' ) ); ?>
<h3>About <?php echo get_the_author() ; ?></h3>
<?php the_author_meta( 'description' ); ?>
<?php endif; ?>
<?php comments_template( '', true ); ?>
</article>
</section>
<?php endwhile; ?>
Link to my site.
6 Answers
Caroline Hagan
12,612 PointsLooks like you are missing a bit of php...
<!-- Start The Loop -->
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
...
<?php the_content(); ?>
...
<?php endwhile; ?>
<div class="pre_nx">
<div class="nav_previous"><?php next_posts_link('Previous'); ?></div>
<div class="nav_next"><?php previous_posts_link('Next'); ?></div>
</div>
...
<?php else : ?>
...
<?php endif; ?>
<!-- End The Loop -->
Or was it just the forum post was missing some text/formatting?
Kevin Esther
8,551 PointsHad some of the code missing amended.
Comparing your code against mine at the moment.
Kevin Esther
8,551 PointsIt was a really easy error.
Won't make this mistake again.
<?php next_posts_link(); ?>
should be
<?php next_post_link(); ?>
It is only post not posts
Notice this after a few hours of trying ever fix on google. Lesson learned.
Caroline Hagan
12,612 PointsIt's always worth checking twenty twelve theme and the Codex for comparison :-)
Kevin Esther
8,551 PointsThanks Caroline. Will do this in the future. Learn by studying the code.
Is there way to check your wordpress tags are correct? some sort online checker.
So annoying. Laughing about it now :)
Caroline Hagan
12,612 PointsNot that I'm aware of - but if you find one, do let us know!
Also, might be worth switching on PHP errors in your wp-config.php file, to show anything awry :-)