Wordpress自定义帖子类型显示类别的图像

I have been trying to get something to work, i have wordpress and also have a custom post type and custom taxonomies, basically i wanted it to show an image on a single post for certain categories but the rest will show a different image.

Here is my code anyone know why this is not working, all it shows is the second image.

<?php   // Get terms for post
$terms = get_the_terms( 'story_category' );
if ( $terms == "global-freebies" || $terms == "usa-freebies" || $terms == "uk-freebies" ){ ?>
<center><span class="domain"><a href="<?php echo esc_url( $post_url ); ?>" target="_blank"><img width="250" src="http://kwikfreebies.com/wp-content/uploads/2017/04/freebie_button.jpg"></a></span></center>
<?php } else { ?>
<center><span class="domain"><a href="<?php echo esc_url( $post_url ); ?>" target="_blank"><img width="250" src="http://kwikfreebies.com/wp-content/uploads/2017/04/site_button.jpg"></a></span></center>
<?php } ?>

</div>

This will solve your issue:

<?php $terms = get_the_terms( $post->ID, 'story_category' );
if ( $terms[0]->slug == "global-freebies" || $terms[0]->slug == "usa-freebies" || $terms[0]->slug == "uk-freebies"  ) :?>
<center><span class="domain"><a href="<?php echo esc_url( $post_url ); ?>" target="_blank"><img width="250" src="http://kwikfreebies.com/wp-content/uploads/2017/04/freebie_button.jpg"></a></span></center>
<?php else : ?>
<center><span class="domain"><a href="<?php echo esc_url( $post_url ); ?>" target="_blank"><img width="250" src="http://kwikfreebies.com/wp-content/uploads/2017/04/site_button.jpg"></a></span></center>
<?php endif;?>

Enjoy!