尝试使用get\\u页面
\'child_of\' => get_the_ID(),
\'parent\' => get_the_ID(),
如果你需要,我可以发布完整的代码
编辑:
if ( is_singular(\'post\') ) {
$args = array(
\'post_type\' => \'attachment\',
\'posts_per_page\' => -1,
\'post_status\' => null,
\'parent\' => $post->ID ,
\'child_of\' => $post->ID,
\'sort_order\' => \'desc\'
);
$attachments = get_pages( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo wp_get_attachment_url( $attachment->ID );
}
}else {
}
}
我希望此代码对您有所帮助