Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get only gallery images #44

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions views/format-gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@

// running this in the view so it can be used by multiple functions

$attachments = get_posts(array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order ID',
));
if ($attachments) {
$galleries = get_post_galleries($post->ID, false);
$attachments = [];
foreach($galleries as $gallery) {
$attachments=$attachments + explode(',',$gallery['ids']);
}
$attachments = array_unique($attachments);
if (!empty($attachments)) {
echo '<ul class="gallery">';
foreach ($attachments as $attachment) {
echo '<li>'.wp_get_attachment_image($attachment->ID, 'thumbnail').'</li>';
echo '<li>'.wp_get_attachment_image($attachment, 'thumbnail').'</li>';
}
echo '</ul>';
}

?>
<p class="none"><a href="#" class="button"><?php _e('Upload Images', 'cf-post-format'); ?></a></p>
</div>
</div>
</div>