Return to Snippet

Revision: 11914
at February 23, 2009 15:15 by trey


Initial Code
<?php
$attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order'));
if ( ! is_array($attachments) ) continue;
$count = count($attachments);
$first_attachment = array_shift($attachments);
?>
<?php echo wp_get_attachment_image($first_attachment->ID); ?>

Initial URL
http://wordpress.org/support/topic/165921

Initial Description

                                

Initial Title
Display the First Image Attachment of a WordPress Post

Initial Tags
wordpress

Initial Language
PHP