Linking featured image with custom field URL
-
Hi – I’m trying to link the featured image using the value from a custom field. This is where I’ve got so far but it only displays the image and not any links at all.
<?php if(has_post_thumbnail()) { $image_url = the_post_thumbnail( 'blog' ); $image_url = $image_url[0]; $external_url = get_post_meta( $postID, 'Website:', true); if ( $external_url ) { echo '<a href="'.$external_url. '" target="_blank"><img src="'.$image_url.'" alt="" /></a>'; } else { echo '<a href="'.get_permalink($postID).'"><img src="'.$image_url.'" alt="" /></a>'; } } ?>
Any help would be great. Thanks
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Linking featured image with custom field URL’ is closed to new replies.