0

How do I get the URL of my featured image?

I am using buffy and I can Call The URL of The post and so on, but can't figure out how to Call The URL of The featured image.

1
1

the_post_thumbnail() is highest level function for it, which will output complete HTML. If you need some lower level parts, digging deeper are nested:

0

Hey by using wp_get_attachment_image_src() to get the featured image url like this

<?php 
    if ( has_post_thumbnail() ) {
        $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large' );
    }
?>

<img src="<?php echo $large_image_url[0]; ?>">
0

You can simply call the following function to get the url of the featured image depending on the size you want to print :

the_post_thumbnail_url( $size );

the size variable might be either a string : (thumbnail, medium, large, full) or a precisized width and height (24*24).

You can learn more about it by visiting this url : https://codex.wordpress.org/Function_Reference/the_post_thumbnail_url

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.