Posted By

nerdsane on 03/09/12


Tagged

image wordpress thumbnail gallery


Versions (?)

Wordpress Excluding Featured Image from Gallery


 / Published in: PHP
 

This snippet will exclude the featured image from the attached images (gallery)

  1. <?php
  2. $thumb_ID = get_post_thumbnail_id( $post->ID );
  3. if ( $images = get_children(array(
  4. 'post_parent' => get_the_ID(),
  5. 'post_type' => 'attachment',
  6. 'post_mime_type' => 'image',
  7. 'exclude' => $thumb_ID,
  8. ))) : ?>
  9. <ul>
  10. <?php foreach( $images as $image ) : ?>
  11. <li><?php echo wp_get_attachment_link($image->ID, 'thumbnail-latest'); ?></li>
  12. <?php endforeach; ?>
  13. </ul>
  14. <?php else: // No images ?>
  15. <!-- This post has no attached images -->
  16. <?php endif; ?>

Report this snippet  

You need to login to post a comment.