Created
February 28, 2015 20:20
-
-
Save slambert/46f42bf4b1f68fc7b325 to your computer and use it in GitHub Desktop.
WordPress Thumbnail Function
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
// Thumbnail Function - this creates a default thumbnail if one is specified | |
function get_thumb ($post_ID){ | |
$thumbargs = array( | |
'post_type' => 'attachment', | |
'numberposts' => 1, | |
'post_status' => null, | |
'post_parent' => $post_ID | |
); | |
$thumb = get_posts($thumbargs); | |
if ($thumb) { | |
return wp_get_attachment_image($thumb[0]->ID); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment