私はこのコードをcodexから直接使用しています。
function echo_first_image ($postID)
{                   
    $args = array(
    'numberposts' => 1,
    'order'=> 'ASC',
    'post_mime_type' => 'image',
    'post_parent' => $postID,
    'post_status' => null,
    'post_type' => 'attachment'
    );
    $attachments = get_children( $args );
    //print_r($attachments);
    if ($attachments) {
        foreach($attachments as $attachment) {
            $image_attributes = wp_get_attachment_image_src( $attachment->ID, 'thumbnail' )  ? wp_get_attachment_image_src( $attachment->ID, 'thumbnail' ) : wp_get_attachment_image_src( $attachment->ID, 'full' );
            echo '<img src="'.wp_get_attachment_thumb_url( $attachment->ID ).'" class="current">';
        }
    }
}
このようにループ内で呼び出します echo_first_image ($post->ID);
関数は呼び出しますが、何も出力されません...私が見ることができる限り、何もありません $attachments
使用している投稿に画像があります。注目の画像やギャラリーではなく、投稿のみです。
私は何か間違ったことをしていますか、それとも最初からコードに何か問題がありますか?