Currently set to Index
Currently set to Follow

Get the Official WPSaviour App Now!

BlogThemes

How to Automatically Link Featured Images to Posts in WordPress

Just lately considered one of our readers requested if it was attainable to mechanically hyperlink featured pictures to weblog posts in WordPress. Most WordPress themes hyperlink featured pictures to posts by default, however some themes could not try this. On this article, we’ll present you the best way to mechanically hyperlink featured pictures to posts in WordPress.

Automatically link featured images to posts in WordPress

Why Hyperlink Featured Photographs to Posts in WordPress?

Photographs are extra participating than textual content. Utilizing featured pictures can increase consumer engagement in your web site.

Normally, featured pictures are massive and take extra space than textual content. They’re extra colourful, therefore extra noticeable. They’re additionally simpler to click on on smaller gadgets like cell phones and tablets.

List25 using featured images to engage users

Nevertheless, in case your publish thumbnails aren’t clickable, then it makes it more durable for customers to view your publish.

Most WordPress themes hyperlink featured pictures to the posts by default. Some themes could not use that method, which makes it tough so that you can correctly make the most of featured pictures.

Having stated that, let’s see how one can mechanically hyperlink featured pictures to posts in WordPress.

Mechanically Hyperlink Featured Photographs to Posts in WordPress

This methodology required you so as to add code into your WordPress information. See our newbie’s information on pasting snippets from net into WordPress.

Merely add this code to your theme’s features.php file or a site-specific plugin.

1
2
3
4
5
perform wpb_autolink_featured_images( $html, $post_id, $post_image_id ) {
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
return $html;
}
add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );

This code merely provides a hyperlink across the code generated to show featured pictures or publish thumbnails in your web site.

This code can even add a hyperlink round featured pictures on single publish pages. In case you don’t need to hyperlink featured pictures on single publish to the identical publish, then use this code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
perform wpb_autolink_featured_images( $html, $post_id, $post_image_id ) {
If (! is_singular()) {
    
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . $html . '</a>';
return $html;
} else {
return $html;
}
}
add_filter( 'post_thumbnail_html', 'wpb_autolink_featured_images', 10, 3 );

We hope this text helped you learn to mechanically hyperlink featured pictures to posts in WordPress. You might also need to see our listing of 14 finest featured picture plugins and tutorials for WordPress.

Download The WPSaviour App Now

Related posts
Beginner’s GuideBlogTips

Top 5 free payment gateway plugins for WordPress in India (2020)

Beginner’s GuideBlogTips

Best WooCommerce International Payment Gateways for WordPress in 2020

Best WordPress PluginsBlog

WordPress 5.4 Will Add Lazy-Loading to All Images

Beginner’s GuideBlog

How to Add a Preloader Animation to WordPress (Step by Step)

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.