This snippet was instrumental on our previous WordPress website (we now use Webflow), so I thought I'd share it with you. It enables you to add an external link to the featured image on the main post page. This feature is handy for linking to client websites, affiliate links or any manner of URLs where linking out to an alternate URL is desirable.

WordPress add External link to Featured Image

Updated for Custom Fields with Gutenburg (see step 2 on how to enable Custom Fields for Gutenburg)Just 3 steps

1. Add the following WordPress snippet to your Wordpress Theme functions.php file

Save your updated functions.php file

2. Ensure that you have WordPress custom fields enabled in your version of WordPress (previously in top admin dropdown). If you are using WordPress 5.0 with Gutenburg and Custom Fields are not visible then click on the 3 vertical button burger menu (top right), head to 'Options' and ensure they are ticked under 'Advanced Fields'.

3. Now compose your post as usual and add the featured image. Then access the Custom Fields panel on your post page and 'Add New Custom Field' ExternalUrl and then add your desired destination external URL in the 'Value' entry like the below and that's it - your featured image will now link externally to the Link set.

External URL WordPress Custom Field

Adding this type of feature is much easier on Webflow with its visual page builder and superior CMS, so we encourage you to take a look. If you stick with WordPress, then we hope you find this snippet useful?