2012-11-09 37 views
0

現在,我讓我的整個WordPress博客顯示the_excerpt而不是the_content。但是,我希望它僅在視頻類別頁面上顯示the_content。現在在content.php文件中,它從我的內容擴展php文件中抓取擴展名「muimedia_post_entry_summary」。在我的內容擴展PHP文件這裏是獲取摘錄(post_entry_summary)的代碼...僅在視頻類別頁面上顯示摘錄?

/* muimedia_post_entry_summary */ 
if (!function_exists('muimedia_post_entry_summary')) { 
function muimedia_post_entry_summary() { 
?> 
<div class="entry-summary"> 
<?php if (has_post_thumbnail()){ ?> 
<a href="<?php the_permalink() ?>" title="<?php the_title_attribute 
(array('before' =>   esc_attr__('Permalink: ', 'muimedia'), 
'after' => '')); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a> 
<?php } ?> 
<div id="categorysummary"> 
<?php the_excerpt(); ?> 
</div> 
</div> 
<?php 
} 
} 

這段代碼獲得各崗位的縮略圖,摘錄..和我想要得到它,只顯示內容在視頻類別頁面上。我試圖保持第一以上代碼,複製它,然後將其更改爲以下:

/* muimedia_post_entry_summary video page */ 
if (!function_exists('muimedia_post_entry_summary') && is_category('videos') ) { 
function muimedia_post_video_entry_summary() { 
?> 
<div class="entry-content"> 
<?php the_content(); ?> 
</div> 
<?php 
} 

}

正如你可以看到我嘗試了「& & is_category」,我也累了「|| is_category」並用它的ID替換類別名稱。我甚至嘗試過改變函數名,所以它是「post_video_entry_summary」(我不認爲這個名字很重要)。我真的不知道還有什麼可以做的:(如果有人能夠幫助我解決這個小問題,那麼這對我來說意味着什麼,真的會,我會去吃午飯,但是,我會讓我的在未來的20分鐘內返回到我的電腦..希望有人會有正確的解決方案,這一些什麼最小的問題!:)

回答

1

使用'in_category(「視頻」)'作爲你的if語句。

<?php 
    if (in_category('videos')) : 
?> 

    // your video code here 

<?php 
    else : 
?> 

    // else show the current stuff 

<?php 
    endif; 
?> 
+0

嗨,不要粗魯,但我認爲這個問題比這個大得多。它與我列出來顯示摘錄僅在視頻我特定的第二代碼做..我想你sugested什麼: /* muimedia_post_entry_summary視頻頁面*/ 如果(in_category(「視頻」)){ \t功能muimedia_post_video_entry_summary(){ \t \t?> \t \t

\t \t \t \t \t \t \t \t \t \t \t \t \t \t
\t \t <?PHP \t}} 我 還試圖is_category,仍然一無所獲。我雖然欣賞的幫助! :) – user1658560

+0

如果其他人有答案,這對我意味着很多! :) – user1658560

+0

是您的類別「視頻」還是您的格式「視頻」? – 100pwd

相關問題