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; ?>

Advertisements

Sr. Software Engineer

Posted in Wordpress

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: