I have created a page called “Gallery” and created new gallery
with 10 images. My page id is 129. I have 10 images in that page id(129)
.
Now my question is, i need a code to fetch those 10 images in wordpress. please anyone help me with a code. Thanks in advance.
Leave a Reply
You must be logged in to post a comment.
Get all images from post.
Here you get frist image such like you get all other images
Use get_children
I used this code to extract all the images from a page gallery in the chosen order. you can include this code in the loop or use it stand alone. just choose the appropriate post_parent code (see bellow the code example).
This example show all images associated to the page id 129, have a look:
$images is now a object that contains all images (related to post id 1) and their information ordered like the gallery interface.
Find the post id you wan to extract images from and insert it into this argument: ‘post_parent’ => 129
you can also use:
‘post_parent’ => $post->ID
If you want to use get_children in a loop, and get the post id from the returned post id.
If you want to exclude the image selected as a featured image i would have a if statement check if the image URL is equal to the featured image URL.