WordPress Custom Category Show image

I Have a Problem, I am trying to show a country Flag on different custom posts in a category, the code i am using works but when there is more than 1 category assigend to a custom post, the images do not show.

Here is my code:

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

Read more here: WordPress Custom Category Show image

Leave a Reply

Your email address will not be published. Required fields are marked *