add external link in Wordpress Featured Image

How to add external link in WordPress Featured Image

How to add external link in WordPress Featured Image? Yes, you can do this plugin or without plugin if you need for any reason. Only 3 step without plugin. So try Now.

Add external link in WordPress Featured Image without Plugin

This is easy to step to add image link in feature step

Total Time: 2 minutes

Step 1: Open function file in theme/child theme folder and insert code

Step 1 Open Function File of Theme Folder

// Code for Add External Link to Featured Image with Custom Field
add_filter(‘post_thumbnail_html’,’add_external_link_on_page_post_thumbnail’,10);
function add_external_link_on_page_post_thumbnail( $html ) {
if( is_singular() ) {
global $post;
$name = get_post_meta($post->ID, ‘ExternalUrl’, true);
if( $name ) {
$html = ” . $html . ”;
}
}
return $html;
}

Step 2: Enable custom field if not enable

Step 2 - Enable Custom Field

You have to enable Custom field, so that you can add link as per your requirement. So tick for custom field.

Step 3: Now Compose/Edit post/page and Insert Custom

Step 3 - Insert External Link for Feature Images

Simply ‘Add New Custom Field’ ExternalUrl and then add required external/internal URL in the ‘Value’ entry as given in screenshot and save or update post.
Now simply refresh your post.

// Code for Add External Link to Featured Image with Custom Field
add_filter('post_thumbnail_html','add_external_link_on_page_post_thumbnail',10);
function add_external_link_on_page_post_thumbnail( $html ) {
if( is_singular() ) {
global $post;
$name = get_post_meta($post->ID, 'ExternalUrl', true);
if( $name ) {
$html = '' . $html . '';
}
}
return $html;
}

Feature Image External Linking through Plugin

You can use simple plugin and do this work easily. So just add below mention plugin and you can add external link.

Feature Image External Linking through Plugin

Simply download – https://wordpress.org/plugins/custom-url-to-featured-image/ and insert.

Example for this work

Plugin for Feature Images External Link

Conclusion:

We have suggest two different method and you can do this yourself. If still problem you can hire wordpress expert at only $5/- and focus on your business.

Alternative, you can view our WordPress Tutorial

1 thought on “How to add external link in WordPress Featured Image”

  1. Thanks. Its work and found same like this code, which work without any plugin.

    Thanks once again for correct code and how to guide.

Leave a Comment

Your email address will not be published. Required fields are marked *