how to get url ONLY of featured image in wordpress

I'm using timthumb.php and need to be able to get the url of the featured image of a post, when I use functions like the_post_thumbnail it does more than just the url.

Here is the code so, the capital letters is where I need to insert the exact url, any help would be great, thanks.

<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> 
    <img src="<?php bloginfo('template_url'); ?>/wp-content/themes/limerickfc/timthumb.php?src=<?php URL OF FEATURED IMAGE ?>&h=760&width=474" alt="" title="<?php the_title(); ?>" />
</a>

Answers


If your "thumbnail" images are large enough to do what you need:

<?php wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>

Otherwise you'll need to go for something like:

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

EDIT: The array(300, 300) bit is the image size you'd like to fetch. WP will substitute any image it has that is at least as large as what you asked for. You can also use 'thumbnail', 'medium', 'large' or 'full' to select one of the pre-configured sizes, as well as any name defined by add_image_size() in your template or plugins.


First get the id of the featured thumbnail image:
$thumb_id = get_post_meta( $post_id, '_thumbnail_id', true );
One way to do it:
$thumb = get_post($thumb_id);
$thumb_url = $thumb->guid;
Another way would be:
$thumb_url = wp_get_attachment_url( $thumb_id );

Be careful about what is stored in the GUID and what is returned by get_attachment_url. The attachment url (depending on configuration) can be the page where the attachment is visitable (not the raw file URL but the page where attachment.php is used).


Need Your Help

Get memory usage of computer in Windows with Python

python memory winapi memory-management pywin32

How can I tell what the computer's overall memory usage is from Python, running on Windows XP?