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:
<?php
/**
* 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(); ?>
<?php
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.
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' ); ?>