• Resolved callender

    (@jimcallender)


    Hiya,

    I have got the thumbnails appearing in the category and homepage.

    However they are not linking to its post.

    How do I do this?

    Thanks in advance,

    Jim C.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter callender

    (@jimcallender)

    I have figured this out.

    http://codex.wordpress.org/Category_Templates#Display_Images_Linking_to_Full_Posts

    <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('thumbnail'); ?></a>

    Another option, just for info…..

    // THIS LINKS THE THUMBNAIL TO THE POST PERMALINK
    
    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;
    }

    instead of adding the_permalink to each use of the_post_thumbnail if you use it multiple times around a theme like I do, the above added to functions.php will make all thumbnails links to the post

    Thread Starter callender

    (@jimcallender)

    Sweet, thats nice of you to post this info Rev.

    Much appreciated!

    J

    sure thing!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How do i link a thumbnail on category/home page to the post?’ is closed to new replies.