Featured Image External Linking
-
I’m having the hardest time trying to accomplish the following: I want to set the featured images on each of my pages to an external link, opening in the same window. So I want the visitors to be able to click my featured images to take them to a link of my choice.
I’ve found others having the same issue but their solutions aren’t working with my setup. I’ve attempted to go the route of creating a custom field ‘externalurl’, placing my URL into the field and then adding some code to template files but I can’t get a clickable featured image. Others have mentioned putting the below code into the page.php file, replacing some thumbnail related code but I don’t have any thumbnail related code in this file.
This is the code i’ve tried pasting into my page template files but 1) I’m not sure what php file to paste this in because I can’t find any references to the featured images. I’m using the Pytheas theme and the site is custom-screws.com.
<?php $name = get_post_meta($post->ID, 'ExternalUrl', true); if( $name ) { ?> <a href="<?php echo $name; ?>"><?php the_post_thumbnail(); ?></a> <?php } else { the_post_thumbnail(); } ?>
Help!!!
- The topic ‘Featured Image External Linking’ is closed to new replies.