How do I get image url only on the_post_thumbnail

I want to know how to get image url on the_post_thumbnail()

Default the_post_thumbnail()

<img width="800" height="533" src="" class="attachment-post-thumbnail wp-post-image" alt="book06" title="book06" />

Here I want grab the src only. How do I filter the_post_thumbnail() only to get

Let me know


You might also try:

If you only have one size thumbnail:

$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) );

Or…if you have multiple sizes:

$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "size" );

Note that wp_get_attachment_image_src() returns an array: url, width, height, is_intermediate.

So if you just want only the image url:

echo $thumbnail[0];



Leave a Comment