If more than 1 image show post link?
check how many posts were returned in your $attachments variable and output your desired markup for each case: $featured = get_post_meta($post->ID,’_thumbnail_id’,true); $attachments = get_children( ‘post_type=attachment&orderby=menu_order&exclude=”.$featured.”&post_mime_type=image&post_parent=”.$post->ID ); if( count( $attachments ) > 1 ): // more than 1 attachment else: // just 1 (or 0) endif;