Skip to content

Instantly share code, notes, and snippets.

@thesadoo
Last active October 3, 2016 11:28
Show Gist options
  • Save thesadoo/d2d9aa8b38702b4818dbd6596d451fdd to your computer and use it in GitHub Desktop.
Save thesadoo/d2d9aa8b38702b4818dbd6596d451fdd to your computer and use it in GitHub Desktop.
Wordpress post thumbnail URL
<?php
function ThumbnailAddress( $id = false, $echo = true, $size = "fullsize" ) {
global $post;
if( !$id ){
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size );
} else {
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id($id), $size );
}
if( $echo == true ){
echo $thumb['0'];
} else {
return $thumb['0'];
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment