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

WordPress From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Creating a Portfolio Single Page

Rich P
Rich P
2,356 Points

The Next & Previous PHP Code Breaking Page

The portfolio single page breaks and won't load when I add in the Next & Previous PHP tags into the code. If I remove them, the page will load.

<?php get_header(); ?> <div class="container">

  <div class="page-header">
    <div class="row">
      <div class="col-xs-9">
        <h1>Portfolio</h1>
      </div>
      <div class="col-xs-3 prev-next">
        <?php next_post_link ( '%link', 'Right' ); ?>

        <?php previous_post_link ( '%link' 'Left' ); ?>
      </div>
    </div>
  </div>

<div class="row">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

  <div class="col-sm-8 portfolio-image">
    <?php
      $thumbnail_id = get_post_thumbnail_id();
      $thumbnail_url = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail-size', true );
      ?>
      <p><a href="<?php the_permalink(); ?>"><img src="<?php echo $thumbnail_url[0]; ?>"></a></p>
  </div>
  <div class="col-sm-4">
    <h1><?php the_title(); ?></h1>
    <?php the_content(); ?>
  </div>
</div>


<?php endwhile; else: ?>
<div class="page-header">
  <h1>Oh no!</h1>
  <p>Uh oh! We couldn't find that page</p>
  <?php the_content(); ?>
  <?php endif; ?>
</div><!--END ROW-->

</div><!--END CONTAINER--> <?php get_footer(); ?>

1 Answer

Stanley Thijssen
Stanley Thijssen
22,831 Points

Hey Rich,

You forgot a comma inside ur code:

<?php previous_post_link ( '%link' 'Left' ); ?>

Should be:

<?php previous_post_link ( '%link', 'Left' ); ?>
Rich P
Rich P
2,356 Points

ha! Thank you!