How to get Images included in Post

is possible to get images added to a post programmatically? I am working on custom template (my first) and I need to display Images added to a post in specific way.(first image as title image and the rest of imgs only render into hidden img tags (will be visible through lightbox slideshow).

So is there any function like get_post_attachments('type'=>'image') whose output I would be able to iterate over a loop?

Thanks for your help

2 s
2

You can use get_posts() (Codex ref for getting Post attachments).

<?php
$args = array( 
    'post_type' => 'attachment', 
    'post_mime_type' => 'image',
    'numberposts' => -1, 
    'post_status' => null, 
    'post_parent' => $post->ID 
); 
$attached_images = get_posts( $args );
?>

Leave a Comment