All you have to do is add this code to the end of your theme’s functions.php file:
add_filter( 'post_thumbnail_html', 'wps_post_thumbnail', 10, 3 );
function wps_post_thumbnail( $html, $post_id, $post_image_id ) {
$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
return $html;
}
Note: If this is your first time adding code snippets in WordPress, then before you do that, it would be better to google something like “How to edit functions.php in Wordress”, so you don’t accidentally break your site.
