How can retrieve post specific attachment all image

For retrieve/get any one post specific attachment all image please use this code.

Copy this code and put in where you want add in your themes core files.
if ( have_posts() ) : while ( have_posts() ) : the_post();
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' =>PUT HERE POST-ID
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo '<div>';

//retrieve all images echo wp_get_attachment_image( $attachment->ID, 'full' ); echo '<div><p>';

//retrieve all images title echo apply_filters( 'the_title', $attachment->post_title ); echo '</p></div></div>'; } } endwhile; endif; ?>

Leave a Reply

Your email address will not be published. Required fields are marked *