Don’t Worry, You’re In The Right Place
A lot of these posts were originally on SureFireWebServices.com. So if you found them through search engines or clicking around, this is their new home :). Enjoy!
0

How to get the path of a featured image in wordpress

I’m using a new plugin and need to find the source code of the featured image on the posts. After some research I found this nice little snippet of code and it works GREAT!!! Now I just need to find out how to only get the uri!! Any help would be much appreciated!

[code language=”php”]
$imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");
echo $imgsrc[0];
[/code]

BAM!

You can also get the width and height by using the array 1 or 2 like this:

$imgsrc[1] returns the width.
$imgsrc[2] returns the height.

Resources: http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

Advertisement
About the Author
What's UP! This is my site, I write 99% of the articles on here. I'm also the owner of SureFireWebServices.com. I help out a lot of developers and designers getting into the web game. Helping is fun for me, so feel free to ask me any questions! I've made courses and have a membership as well to help get you on your feet!

0 comments on How to get the path of a featured image in wordpress

  1. Anand Godar says:

    Really nice , it solved my problem. Thanks dude

    1. Jonathan says:

      No Problem! =)

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top