Return to Snippet

Revision: 56102
at March 9, 2012 23:17 by nerdsane


Initial Code
<?php
	$thumb_ID = get_post_thumbnail_id( $post->ID );
	if ( $images = get_children(array(
			'post_parent' => get_the_ID(),
			'post_type' => 'attachment',
			'post_mime_type' => 'image',
			'exclude' => $thumb_ID,
		))) : ?>
		<ul>
		<?php foreach( $images as $image ) :  ?>
			<li><?php echo wp_get_attachment_link($image->ID, 'thumbnail-latest'); ?></li>
		<?php endforeach; ?>
	</ul>
<?php else: // No images ?>
	<!-- This post has no attached images -->
<?php endif; ?>

Initial URL


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

Initial Title
Wordpress Excluding Featured Image from Gallery

Initial Tags
image, wordpress

Initial Language
PHP