Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get ALL gallery images from a post, NOT limited to only the first post.
<?php
$galleries = get_post_galleries( $post, FALSE );
$i = 0;
foreach ( $galleries as $key => $gallery) {
$images = $gallery['src'];
foreach ($images as $key => $img) {
if( $i < 4 ) {
echo '<img src="' . $img . '" alt="">';
}
$i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment