Skip to content

Instantly share code, notes, and snippets.

@michaeloeser
Created April 5, 2013 13:27
Show Gist options
  • Save michaeloeser/5319254 to your computer and use it in GitHub Desktop.
Save michaeloeser/5319254 to your computer and use it in GitHub Desktop.
Automatically link all Post Thumbnails to their Posts
// Link all Post Thumbnails to their Posts
add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
function my_post_image_html( $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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment