Link featured post thumbnail in wordpress


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // THIS LINKS THE THUMBNAIL TO THE POST PERMALINK
  2.  
  3. add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
  4.  
  5. function my_post_image_html( $html, $post_id, $post_image_id ) {
  6.  
  7. $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
  8.  
  9. return $html;
  10. }

URL: http://wordpress.org/support/topic/making-post-thumbnail-link-to-post

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.