I have a page within WordPress called 'Gallery', the page ID is 128, and I need to display only the gallery images from that page on a different page with a different ID. The images were uploaded using the standard WordPress gallery functionality.
I've been trying to use get_children
and a foreach
loop to achieve it, but I can't seem to get only the gallery images from the page I need (ID 128).
Here's what I have so far:
$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' );
}
}
How can I display gallery images from a WordPress page, on a different page?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire