Get url from thumbnail WordPress

0
66

To obtain the url of a WordPress Thumbnail to be able to use it in your theme, we are going to use the WordPress function, one of them
 wp_get_attachment_image_src and get_post_thumbnail_id.

$foto = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' ); $src = $foto['0']; echo '<img src="'.$src.'">';

Instead of thumbnail we can use medium, large or full.

The traditional way that WordPress gives us to obtain the outstanding image of the post, is the following

if ( has_post_thumbnail() ) { the_post_thumbnail(‘thumbnail’); // It gives us <img src=”IMAGE” class=”SEIZE” /> }

LEAVE A REPLY

Please enter your comment!
Please enter your name here