How to add an external url to a featured image
-
I’ve been trying to find a simple way to add an external url to a featured image on a page. Where someone will click on the featured image and a new external url will open in another window.
I found this code Example #1:
‘<?php $name = get_post_meta($post->ID, ‘ExternalUrl’, true); ?>
“<img />‘I added the name ExternalUrl myself.
I also added a custom field to my page:
Name: ExternalUrl
Value: https://www.google.comNow my problem….
1. Where do I put the code (Example #1)? Does it go in the functions.php? or another file?
2. Does “get_post_meta” work for pages also?If anyone can give me their expert guidance on this, I would truly appreciate it. I know I’m close, (I think, I hope) but I haven’t really a clue as to where this code goes. Thanks.
- The topic ‘How to add an external url to a featured image’ is closed to new replies.