1
我有一個問題,我試圖顯示一個國家的不同類別的自定義帖子,我使用的代碼作品,但是當有一個以上的類別assigend自定義帖子,圖像不顯示。WordPress自定義類別顯示圖像
這裏是我的代碼:
<?php
$terms = get_the_terms(get_the_ID(), 'story_category');
if ( $terms[0]->slug == "usa-freebies") :?>
<img class="country" width="23" src="http://www.iconarchive.com/download/i47330/icons-land/vista-flags/United-States-Flag-1.ico">
<?php elseif ($terms[0]->slug == "uk-freebies") : ?>
<img class="country" width="23" src="http://www.iconarchive.com/download/i47324/icons-land/vista-flags/United-Kingdom-Flag-1.ico">
<?php elseif ($terms[0]->term_taxonomy_id == "698") :?>
<img class="country" width="21" src="https://cdn2.iconfinder.com/data/icons/Siena/256/globe%20blue.png">
<?php endif; ?>
你的先生是一個天才要比 – Brian
此外,僅供參考,您可以使用'的print_r($計算)'來看看你的數據的結構。這將有助於你瞭解你的數據 –
非常感謝,當我試圖找出代碼時,我將開始使用它。 – Brian