La funzione Worpress che vi proponiamo oggi ottiene tutte le immagini allegate da un WP-Post, restituendo solo la miniatura della prima immagine caricata nel post corrente.
function get_post_thumbnail($postID) {
$files = get_children(‘post_parent=’.$postID.‘&post_type=attachment&post_mime_type=image’);
if($files) :
$keys = array_reverse(array_keys($files));
$image = wp_get_attachment_image($keys[0], ‘thumbnail’, false);
return $image;
else:
// foo
endif;
}
fonte: www.sastgroup.com






