• Hi!

    I’d like to find a way to echo the value of the url of the image defined as the_post_thumbnail.

    So far <?php the_post_thumbnail(); ?> returns the complete image, but I would like to be able to echo only the url.

    Is that possible?

    Thank you for your help!

Viewing 3 replies - 16 through 18 (of 18 total)
  • Found in another thread:

    <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 300,300 ), false, '' ); echo $src[0]; ?>

    300,300 represents the dimension of your thumbnail. In my case the smallest being 350 x whatever. It will automatically choose the closest size to your thumbnail.

    hey, i’m using this code to show today’s event in the sidebar:

    <?php $temp_query = $wp_query; ?>
    
    <?php 
    
    $today = getdate();
    query_posts('category_name=Events&posts_per_page=1&year=' .$today["year"] .'&monthnum=' .$today["mon"] .'&day=' .$today["mday"] );
    ?>
    
    <?php while (have_posts()) : the_post(); ?>
    
    <div style="float:left;" class="thickbox"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_post_thumbnail( array(92,69) ); ?></a></div>
    
    <b><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></b>
    <?php the_excerpt(); ?>
    
    <div class="deezclear"></div>
     <?php endwhile; ?>
    <?php $wp_query = $temp_query; ?>

    The thumbnail currently links to the post url, i want to make it link to the full size image instead.
    I gather that this is the code to use:
    wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
    but i’m not sure how to apply it…

    i know that i need to “echo” it, but i can’t get the syntax right.
    any chance someone could show me how to put those codes together?

    thanks!

    @tenaciousjk Thanks, this worked perfectly for me. x

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘echo the_post_thumbnail url’ is closed to new replies.