在您试图拉入第一幅图像的页面模板上(如果是帖子本身,那么是single.php),您可以使用以下代码而不是\\u post\\u缩略图
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 );
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">\';
}
}
}