我使用以下代码在父帖子页面上显示附件:
$args = array(\'post_type\' => \'attachment\', \'post_mime_type\' => \'image\', \'order\'=> \'ASC\', \'numberposts\' => -1, \'post_status\' => null, \'post_parent\' => $post->ID );
$attachments = get_posts($args);
if ($attachments) {
foreach ( $attachments as $attachment ) {
$attachments_url[] = $my_image;
$attachments_caption[] = get_the_excerpt();
}
}
问题是摘录并没有得到附件的标题,而是帖子的摘录。
您知道如何显示附件的标题吗?非常感谢。