How to Automatically Link Featured Images to Posts in WordPress

Recently one of our readers asked if it was possible to automatically link featured images to blog posts in WordPress. Most WordPress themes link featured images to posts by default, but some themes may not do that. In this article, we will show you how… Read More »

The post How to Automatically Link Featured Images to Posts in WordPress appeared first on WPBeginner.

Recently one of our readers asked if it was possible to automatically link featured images to blog posts in WordPress. Most WordPress themes link featured images to posts by default, but some themes may not do that. In this article, we will show you how to automatically link featured images to posts in WordPress.

Automatically link featured images to posts in WordPress

Why Link Featured Images to Posts in WordPress?

Images are more engaging than text. Using featured images can boost user engagement on your site.

Usually, featured images are large and take more space than text. They are more colorful, hence more noticeable. They are also easier to click on smaller devices like mobile phones and tablets.

List25 using featured images to engage users

However, if your post thumbnails aren’t clickable, then it makes it harder for users to view your post.

Most WordPress themes link featured images to the posts by default. Some themes may not use that approach, which makes it difficult for you to properly utilize featured images.

Having said that, let’s see how you can automatically link featured images to posts in WordPress.

Automatically Link Featured Images to Posts in WordPress

This method required you to add code into your WordPress files. See our beginner’s guide on pasting snippets from web into WordPress.

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

function 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 simply adds a link around the code generated to display featured images or post thumbnails on your website.

This code will also add a link around featured images on single post pages. If you don’t want to link featured images on single post to the same post, then use this code.

function 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 article helped you learn how to automatically link featured images to posts in WordPress. You may also want to see our list of 14 best featured image plugins and tutorials for WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Automatically Link Featured Images to Posts in WordPress appeared first on WPBeginner.

How to Crop and Edit WordPress Post Thumbnails

Are you frustrated with automated WordPress post thumbnail sizes which crops the image from the middle cutting off the sides? Looking for an easy solution to properly crop and scale post thumbnails? In this article, we will show you how to crop and edit WordPress… Read More »

To leave a comment please visit How to Crop and Edit WordPress Post Thumbnails on WPBeginner.

Are you frustrated with automated WordPress post thumbnail sizes which crops the image from the middle cutting off the sides? Looking for an easy solution to properly crop and scale post thumbnails? In this article, we will show you how to crop and edit WordPress post thumbnails which allows you to fix the image crop position.

A WordPress site showing a featured image on a sticky post

First thing you need to do is install and activate the Post Thumbnail Editor plugin. Upon installation, you can create a new post or edit an existing one.

Next, go to the Featured Image section and upload a new featured image or post thumbnail. You will be able to see a new link below the featured image for Post thumbnail editor.

Launch post thumbnail editor from the post editor screen

When you click on the link, it will open the featured image in the post thumbnail editor where you can crop the image size. Simply select the image sizes you want to edit from the right hand column. Take the mouse over to the image and then drag across the image to select the area you want to crop and click on the crop and save button.

Editing post thumbnail

For more settings you can click on the options button which will display additional settings. You can enter an aspect ratio to maintain during cropping. You can also rotate the image and choose a jpeg compression level.

additional options for thumbnail editor

Editing Older Thumbnails

Post Thumbnail Editor can also be used to edit any image uploaded to your WordPress site. You need to visit Media » Library and take the mouse over to any image. You will notice a link to edit thumbnails.

Editing thumbnails for old images in WordPress media library

Clicking on it will open the image in post thumbnail editor where you can crop and edit the image just like you did for the featured image on the post editing screen.

Editing thumbnails for an older image

Editing an old image will also affect the post where this image is used as featured image or post thumbnail. The newly cropped and saved size will now replace the old thumbnail.

Important: Only the image sizes you select from the right hand column will get affected by the change. Your original image will still be there, and you can still edit the image and make changes if necessary.

We hope this article helped you learn how to edit post thumbnails and featured images in WordPress without changing your theme files. You may also want to check out our tutorial on how to set a default fallback image for post thumbnails in WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

To leave a comment please visit How to Crop and Edit WordPress Post Thumbnails on WPBeginner.