Skip to content

Instantly share code, notes, and snippets.

@tommaitland
Created August 12, 2013 10:42

Revisions

  1. tommaitland created this gist Aug 12, 2013.
    10 changes: 10 additions & 0 deletions snippets.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <?php
    $gallery = get_children( 'posts_per_page=5&post_type=attachment&post_mime_type=image&post_parent=' . $post->ID );
    $attr = array(
    'class' => "attachment-$size wp-post-image",
    );
    foreach( $gallery as $image ) {
    echo '<a href="' . wp_get_attachment_url($image->ID) . '" rel="gallery-' . get_the_ID() . '">';
    echo wp_get_attachment_image($image->ID, 'thumbnail', false, $attr);
    echo '</a>';
    }