Skip to content

Instantly share code, notes, and snippets.

@marushu
Last active February 21, 2016 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marushu/0fdc4a2d1df16fce3c22 to your computer and use it in GitHub Desktop.
Save marushu/0fdc4a2d1df16fce3c22 to your computer and use it in GitHub Desktop.
Get post thumbnail image's url.
<?php
if( has_post_thumbnail() ) {
$thumbnail_id = get_post_thumbnail_id( get_the_ID() );
$image_obj = wp_get_attachment_image_src( $thumbnail_id, 'full' );
echo '<pre>';
print_r( $image_obj[0] );
echo '</pre>' . "\n";
$image_url = esc_url( $image_obj[0] );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment