I am working in Wordpress trying to customize post layouts and am having trouble with a bit of php I've tried implementing.
I am trying to display an image in the post based on the value in a particular field in that post. For example, the field name is 'region' and I want to make it so if someone chooses 'NA' from that field then it displays one image in the post. If someone chooses 'EU' from that field then it will display another image in the post.
Below is the code that I am trying to use but for some reason it is not working and instead just displays both images for 'EU' and 'NA' at the same time.
<?php if( get_field('region') == 'NA' ) { ?>
<img src="https://www.esrnetwork.com/wp-content/uploads/2016/12/NA.png" width="25" height="25"/>
<?php } elseif ( get_field('region') == 'EU' ){ ?>
<img src="https://www.esrnetwork.com/wp-content/uploads/2016/12/EU.png" width="25" height="25"/>
<?php } else { ?>
<?php } ?>
I have very little coding experience and any help would be greatly appreciated.