Last active
May 19, 2018 03:20
-
-
Save Page-Carbajal/1da33491ef751fdbc18f to your computer and use it in GitHub Desktop.
WordPress - Get Post Thumbnail URL
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 | |
/** | |
* Return the Post Thumbnail URL if $post has thumbnail | |
* $post is a WordPress Post Object | |
* @param $post | |
* @return string | |
*/ | |
private function getPostThumbnailURL( $post ){ | |
if ( has_post_thumbnail( $post->ID ) ){ | |
$img_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); | |
return $img_src[0]; | |
} | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment