2012-01-25 32 views
0

我已經設置爲使用後格式畫廊和視頻除了標準。我正在編輯loop-single.php,爲每個帖子格式提供不同的佈局,但是我要爲每個帖子格式包含get_template_part。WordPress的:後格式single-loop.php使用get_template_part

這是我有:

<?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. ?> 


?> 

它想出一個錯誤,當我測試:

解析錯誤:語法錯誤,意想不到的T_CONSTANT_ENCAPSED_STRING在/ home/judddev /的public_html /音調/ wp-content/themes/pitch/loop-single.php on line 26

任何幫助將不勝感激。

+0

什麼是26行? – Toto

+0

get_template_part('news''gallery'); //新聞圖庫模板(news-gallery.php)Apprently – Guy

回答

1

添加

get_template_part( '新聞', '畫廊')之間的逗號;

+0

出現新錯誤解析錯誤:語法錯誤,在40行/public_html/pitch/wp-content/themes/pitch/loop-single.php出現意外的'<' ,這是<?php結尾; //循環結束。 ?> – Guy

+0

什麼是40線? –

+0

<?php endwhile; //循環結束。 ?> – Guy

0

添加逗號:

get_template_part('news', 'gallery'); 
       here ___^ 

,並在oher調用get_template_part

+0

出現新錯誤解析錯誤:語法錯誤,在第40行的/public_html/pitch/wp-content/themes/pitch/loop-single.php出現意外的'<',<?php endwhile; //循環結束。 ?> – Guy

0
<?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; ?> 

只需要從這個開關使用的這些:

<?php endwhile; ?> 


    ?> 

這個

?> 

    <?php endwhile; ?> 
相關問題