fbpx
How to Get WordPress Featured Image Source (img src)

How to Get WordPress Featured Image Source (img src)

With the WordPress function: wp_get_attachment_image_src, you can get the img src of the featured image.

Instructions
Add this code to your page/post template file where you want to use the featured image source.

<?php
 $imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");
 echo $imgsrc[0];
?>

WordPress Snippet Info

Tested with Wordpress v. NA

How to Get WordPress Featured Image Source (img src)
4.7 (94.44%) 36 vote[s]
Please report broken snippets.
Report Broken Snippet
WordPress Hosting

Recent Comments