Skip to content

Instantly share code, notes, and snippets.

@smjuber
Forked from gam3ov3r/wp-attachment-gallery.php
Created September 30, 2018 20:04
Show Gist options
  • Select an option

  • Save smjuber/97abd36380ce8f74b655ca6c7ae0b41f to your computer and use it in GitHub Desktop.

Select an option

Save smjuber/97abd36380ce8f74b655ca6c7ae0b41f to your computer and use it in GitHub Desktop.

Revisions

  1. @isGabe isGabe created this gist Jul 4, 2013.
    19 changes: 19 additions & 0 deletions wp-attachment-gallery.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    <?php
    $args = array(
    'post_type' => 'attachment',
    'numberposts' => -1,
    'post_status' => null,
    'post_parent' => $post->ID
    );

    $attachments = get_posts( $args );

    if ( $attachments ) {
    echo '<ul id="gallery" class="thumb-grid">';
    foreach ( $attachments as $attachment ) {
    $large_image = wp_get_attachment_image_src($attachment->ID,'large',false);
    echo '<li><a href="' . $large_image[0] . '">'. wp_get_attachment_image( $attachment->ID, 'thumbnail' ) .'</a></li>';
    }
    echo '</ul>';
    }
    ?>