728x90
This is snippet that we’ve used for ages on our site so I thought I’d share it with you. What it enables you to do is add an external link to the featured image on the main post page. This is particularly useful 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 WordPress 5.0 (see step 2 on how to enable Custom Fields for Gutenburg)
Just 3 steps
- Add the following WordPress snippet to your WordPress Theme functions.php file
Save your file
- 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 then you’ll find they have been inexplicably removed and you’ll need to add them back in with the WordPress Custom Fields for Gutenberg plugin. Download and install it.
- Now compose your post as usual and add the featured image. Then access the Custom Fieldspanel 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.
You can test this feature by clicking the Featured Image on this page and this will take you back to the Slick Media homepage in a new window
'WEB > WP(WordPress)' 카테고리의 다른 글
How To Change Your WordPress Website’s Domain Name (0) | 2019.04.27 |
---|---|
How to quickly increase the All-in-One WP Migration plugin upload limit (0) | 2019.04.27 |
How To Auto Redirect Users After Logout In WordPress (0) | 2019.03.05 |
How to override the woocommerce.css in the parent theme? (0) | 2019.03.05 |
Does Wordpress Provide Native Datepicker in Admin? (0) | 2018.06.04 |