我在WordPress中有一个名为“Gallery”的页面,页面ID为128,我只需要在另一个具有不同ID的页面上显示该页面中的Gallery图像。这些图像是使用标准WordPress Gallery功能上载的。
我一直想用get_children
和aforeach
循环来实现它,但我似乎无法从我需要的页面(ID 128)中仅获取图库图像。
以下是我目前掌握的情况:
$images = get_children( array(
\'post_parent\' => 128,
\'post_type\' => \'attachment\',
\'post_mime_type\' => \'image\',
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'numberposts\' => 999
) );
if ( $images ) {
// looping through the images
foreach ( $images as $attachment_id => $attachment ) {
echo wp_get_attachment_image( $attachment_id, \'full\' );
}
}
如何在其他页面上显示WordPress页面中的库图像?