kk4uga
Member
Posted 10 months ago #
I want WP to automatically add an image and then a link to the single.php based on the Tag or Tags in the post. Can this be accomplished?
This is similar to a Related Posts feature, but I want to try and link to a specific page (with an image to the left of the link) each time.
It should be possible using get_the_tags. Something like:
<?php
$posttags = get_the_tags();
if ($posttags && in_array( 'wibble',$posttags) ) :>
[ output image & link ]
endif;?>
should work within the Loop.
kk4uga
Member
Posted 10 months ago #
Thanks.
How do I specify which tag and which image to pull in?
Replace wibble with the tag that you want to use. As for which image to use - that's up to you.