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.

  • 1
    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". Jan 25, 2012 at 13:59

1 Answer 1


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' ); ?>

  • Good catch! My eyes glossed right over that. Jan 25, 2012 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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