Last active
January 27, 2017 13:05
-
-
Save michaelwilhelmsen/3a7d52d89074ef21e1e07ffc1e120f93 to your computer and use it in GitHub Desktop.
Get the featured image url. For situations where you just need the img src of the featured image.
Use the function provided for easy usage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $fi_src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'thumbnail_size' ); | |
| $fi_url = $fi_src[0]; | |
| // Returns featured image url, optional size argument. | |
| // Use like this: get_featured_image_url('thumbnail'); | |
| function get_featured_image_url( $size = "full" ) { | |
| global $post; | |
| $fi_src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size ); | |
| $fi_url = $fi_src[0]; | |
| return $fi_url; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment