theme development – Displaying all images from a WordPress post (including media library)
Question
With this function, I’m getting only those images that I uploaded using the upload button in the post section. But, if I add an image from the media library in a post, it’s now showing. I want to show all the images from the post.
$attachments = get_children(array(
'post_parent' => $post->ID,
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID'));
foreach($attachments as $att_id => $attachment) {
$full_img_url = wp_get_attachment_url($attachment->ID);
echo wp_get_attachment_image($attachment->ID, 'full');
}
0
3 weeks
2023-01-06T14:32:48-05:00
2023-01-06T14:32:48-05:00 0 Answers
0 views
0
Leave an answer