I have noticed that using the post_thumbnail() function in Wordpress inserts the image including the img-tag. Is there a way to have it insert ONLY the src of that image?
Sofar i have tried this
$image = get_the_post_thumbnail( $post->ID, 'thumbnail' ); echo $image;
but it just exports the same. Any ideas? thanks in advance for your help :)
The get_the_post_thumbnail() WordPress function will allow you to get the featured image and display it using your theme or plugin. In this article, we will teach you how to use the get_the_post_thumbnail() function to display featured images anywhere you want to.
To get the URL of a post thumbnail you need to add code to the theme template you are customizing. To learn more, refer to our guide on how to add custom code in WordPress. If you simply wanted to display the post thumbnail, then you could paste this code into the template you are working on, inside the WordPress loop.
Adding Post Thumbnail or Featured Image in WordPressIn the content editor, you'll find the featured image tab in the right column. You need to click on the 'Set Featured Image' area, and this will bring up the WordPress media uploader popup.
Found answer. Thanks anyway.
<?php
//Get the Thumbnail URL
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array(320,240), false, '' );
echo $src[0];
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With