WordPress.org

Support

Support » Plugins and Hacks » Hacks » display images in a post as a group in attachemnt

display images in a post as a group in attachemnt

  • sannu3250
    Member

    @sannu3250

    this bellow code display all the images in all the post .. but i want to show only images in the there particular post and loop the images … can you alter the code and make possible .. thanks in advance ..

    <?php

    $args = array(
    ‘post_type’ => ‘attachment’,
    ‘numberposts’ => -1,
    ‘post_status’ => null,
    ‘post_parent’ => null, // any parent
    );
    $attachments = get_posts($args);
    if ($attachments) {
    foreach ($attachments as $post) { ?>

  • <?php
    setup_postdata($post);
    the_attachment_link($post->ID, true);
    ?>
  • <?php
    }
    }

    ?>

  • The topic ‘display images in a post as a group in attachemnt’ is closed to new replies.