Last active
January 11, 2019 06:14
-
-
Save ronipl/c7bad0d00b8b31fbe0cb9cd517e9ff0b to your computer and use it in GitHub Desktop.
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
function get_the_first_image() { | |
$files = get_children('post_parent='.get_the_ID().'&post_type=attachment&post_mime_type=image'); | |
if($files) : | |
$keys = array_reverse(array_keys($files)); | |
$j=0; | |
$num = $keys[$j]; | |
$image=wp_get_attachment_image($num, 'large', false); | |
$imagepieces = explode('"', $image); | |
$imagepath = $imagepieces[1]; | |
$thumb=wp_get_attachment_thumb_url($num); | |
print "<img src='$thumb' class='thumbnail' />"; | |
endif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment