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 WordPress Theme Development Custom Post Type Templates in WordPress The Portfolio Single Page

Shannon Paine
Shannon Paine
1,348 Points

I'm getting a 500 Error for creating the custom type template for single-portfolio.php. Any idea on how to fix it?

Here is my code:

<?php get_header();?>

<section class="two-column row no-max pad">
  <div class="small-12 columns">
    <div class="row">
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> 
      <!-- Primary Column -->
      <div class="small-12 medium-7 medium-offset-1 medium-push-4 columns">
        <div class="primary">

          <?php the_field('images'); ?>

      </div>
    </div>

<!-- Secondary Column --> <div class="small-12 medium-4 medium-pull-8 columns"> <div class="secondary">

        <h1><?php the_title(); ?></h1>
        <p><?php the_field('description');?></p>

      </div>
    </div>

    <?php endwhile(); endif; ?>

   </div>
  </section>  

<?php get_footer();?>

Also, my filename is titled: "single-portfolio_piece.php" because the Post Type I created is called: "portfolio_piece". Any idea on what might be causing my 500 error?

1 Answer

Shannon Paine
Shannon Paine
1,348 Points

Found the problem, its in "<?php endwhile(); endif; ?>". When I get rid of the '()' I'm able to fix the 500 Error. So the correct code to end the loop for this page is "<?php endwhile; endif; ?>". Good luck to all of you WordPress Theme Development learners! Hope my struggles help you.

Christopher Brennan
Christopher Brennan
325 Points

Appreciate you posting up your solution. I ran into this as well. Thanks!

Alan Mills
Alan Mills
31,712 Points

Me too!! Thank you for posting this! SOMEBODY UPDATE THIS COURSE, PLEASE!