Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress <?php the_post_thumbnail( 'full' ); ?> without the img-tag

Tags:

php

wordpress

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 :)

like image 363
Matthew Pateman Avatar asked Nov 14 '10 23:11

Matthew Pateman


People also ask

What is The_post_thumbnail?

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.

How do I get a thumbnail URL in WordPress?

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.

How do you call a post thumbnail in WordPress?

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.


1 Answers

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];
?>
like image 187
Matthew Pateman Avatar answered Oct 20 '22 23:10

Matthew Pateman