• I may be overlooking something, but why does the POST THUMBNAIL not “automagically” link to either the post or to a full size image of the thumbnail?

    Is there something I am missing? Can/how/where can I put in maybe some php to make the thumbnail do this?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter DocEroc

    (@doceroc)

    Ok, I have started this on my own.
    For the ARCHIVES page, you would use this:

    <div class="entry">
    <a href="<?php the_permalink() ?>"><?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(200,160), array("class" => "alignleft post_thumbnail")); } ?></a>

    Placing the ANCHOR before the thumbnail and then closing the anchor just after.
    So for the other pages, basically the same thing, so I will follow up…

    Thread Starter DocEroc

    (@doceroc)

    <a href="<?php the_permalink() ?>">

    That is the same process for the main index template page to link that image to the post as well.

    Still looking for the code to pull the full-size image of the thumbnail

    Hi, I had a similar question, this is how i managed the full-size image question :

    <?php $thumb_id = get_post_thumbnail_id( $post->ID );?>
    <?php $image = wp_get_attachment_image_src( $thumb_id,'full' ); ?>
    <?php echo $image[0]; ?>

    In the first step i get the thumbnail Id
    The second allows me to get the image src info (cf. wp_get_attachment_image_src) in full size.
    the last echoes the first value returned wich is the url.

    mrfletch

    (@mrfletch)

    Thank you foronca, this is exactly what I needed. This should have been built into post-thumbnails when it was release. Can’t believe they overlooked it.

    -Paul

    esmi

    (@esmi)

    They didn’t. You can set the size of the post thumb and even create custom thumbs using set_post_thumbnail_size() and add_image_size() respectively.

    fert

    (@felixo)

    But there seems to be no way to have the thumbnail link to the_permalink. Or am I oevrlooking something. It seems obvious to me that the thumbnail should link to the_permalink. On every page with excerpts. Is there a “standard” way to accomplish this?

    mghch

    (@mghch)

    Finally got it working and is reducing my bounce rate already!

    It works really well with the Cover WP theme

    What???!!! How did you guys do this??! I can’t figure it out! Help!

    // 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;
    }

    in functions.php links all post thumbnails to the permalink

    ….Rev. Voodoo

    Fantastic! thanks for sharing…

    @ Rev. Voodoo
    thanks, sharp tip !

    Anonymous User

    (@anonymized-5741777)

    @ Rev. Voodoo

    Thanks, finally got the featured images linked to their posts! Although the code works fine, I can’t say I completely understand it. Could you (or anyone else) please tell me what the numbers 10 and 3 stand for?

    Thanks very much in advance.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘Making POST THUMBNAIL link to post’ is closed to new replies.