Last active
December 18, 2015 09:19
-
-
Save asbjornu/5760192 to your computer and use it in GitHub Desktop.
WordPress' missing the_post_thumbnail_url() function.
This file contains 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
<?php | |
/** | |
* Outputs the URL of the "Featured Image", also known as "Post Thumbnail". | |
* @param $post_id (optional) The ID of the Post whose Thumbnail you wish to output. When used within "The Loop", this parameter can be ommitted. | |
* @return void | |
*/ | |
function the_post_thumbnail_url($post_id = false) { | |
global $post; | |
if (!$post_id) { | |
$post_id = $post->ID; | |
} | |
$thumbnail_id = get_post_thumbnail_id($post_id); | |
echo wp_get_attachment_url($thumbnail_id); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment