WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have set up to use post formats gallery and video in addition to the standard. I am editing the loop-single.php to give it different layouts for each post format, but I'm to include get_template_part for each post format.

This is what I have:

 * The loop that displays a single post.
 * The loop displays the posts and the post content.  See
 * http://codex.wordpress.org/The_Loop to understand it and
 * http://codex.wordpress.org/Template_Tags to understand
 * the tags used in it.
 * This can be overridden in child themes with loop-single.php.
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.2

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


    if ( has_post_format( 'gallery' )) {
      // code to display the gallery format post here

      get_template_part( 'news' 'gallery' ); // News Gallery Template (news-gallery.php) 

    } else if (has_post_format('video')) {
       // stuff to display the video format post here

        get_template_part( 'news' 'video' ); // News Gallery Template (news-video.php) 

    }else {
       // code to display the normal format post here

        get_template_part( 'news' 'standard' ); // News Gallery Template (news-standard.php) 


    <?php endwhile; // end of the loop. ?>


It is coming up with an error when I'm testing:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/judddev/public_html/pitch/wp-content/themes/pitch/loop-single.php on line 26

Any help would be greatly appreciated.

share|improve this question
There is a far easier way to do this. Just call get_template_part( 'news', get_post_format() );, which will include e.g. news-gallery.php for the gallery post format. Your fallback template-part file would be news.php, since get_post_format() returns false for "standard". – Chip Bennett Jan 25 '12 at 13:59

You are missing a comma in the arguments for get_template_part.

Instead of <?php get_template_part( 'news' 'video' ); ?> it should be <?php get_template_part( 'news','video' ); ?>

share|improve this answer
Good catch! My eyes glossed right over that. – Chip Bennett Jan 25 '12 at 14:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.