【发布时间】:2015-10-06 00:37:18
【问题描述】:
我在 WordPress 中有一个名为“Gallery”的页面,页面 ID 为 128,我只需要在具有不同 ID 的不同页面上显示来自该页面的画廊图像。图片是使用标准的 WordPress 图库功能上传的。
我一直在尝试使用get_children 和foreach 循环来实现它,但我似乎无法仅从我需要的页面(ID 128)中获取画廊图像。
这是我目前所拥有的:
$images = get_children( array(
'post_parent' => 128,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC'
) );
if ( $images ) {
// looping through the images
foreach ( $images as $attachment_id => $attachment ) {
echo wp_get_attachment_image( $attachment_id, 'full' );
}
}
如何在不同的页面上显示来自 WordPress 页面的图库图片?
【问题讨论】: