I would like to add links to a featured image on some of my single posts. These links need to be unique in a way that it adds my Amazon Affiliate ID.
I made a custom field called “az-post” which I populate when making the post (or mass importing via CSV). To test things out I added the following code to my post-head.php.
<div class=”single-post-thumb”>
<?php if(get_field(‘az-post’)): ?>
<a href=”http://www.amazon.com/dp/<?php the_field(‘az-post’); ?>?tag=myamazonid-20″><?php tie_thumb( $size ); ?></a>
<?php endif; ?>
</div>
With my affiliate ID entered in the “az-post” custom field…everything works as intended.
The problem is when I have a post with no affiliate id in “az-post”. The featured image does not display in the single post.
How would I get the following logic:
If I make a post that uses my affiliate id via custom fields, then it should append a URL to the featured image with my amazon affiliate id. (like the example code above)
IF a post does NOT have my affiliate ID entered THEN use the original theme code below:
<div class=”single-post-thumb”>
<?php tie_thumb( $size ); ?>
</div>
Thanks!