How to get gallery images?
I have some images uploaded in wordpress posts (eg. post#1, and post#2). Now I’ve created a new post (eg. Post#3), and in this post I have inserted the WordPress 3.5 gallery, I did not upload any image in the post#3, instead I used the images from the post#1 and post#2.
Now in the post#3, I would like to get the links to the images, but I can not seem to get. I am using the following code:
$attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' =>'image') );
foreach ( $attachments as $attachment_id => $attachment ) {
echo wp_get_attachment_image( $attachment_id, 'medium' );
}
It will show only the image if I upload in the post, but it won’t show the image if I add from the other posts. So, how can I get the links to the images which are added in the gallery but not uploaded.
Thanks for any help.
Leave an answer
You must login or register to add a new answer .