A collection of web design related ramblings and nonsense

WordPress: Excluding Featured Image from Gallery

June 5th, 2011

While I’m working on my new site I wanted to display a gallery but exclude the featured image / post thumbnail from gallery because this would be a custom thumbnail size and would look rubbish in the gallery.

In wordpress you can pass attachment IDs of any image you want to exclude from the gallery. So all you have to do is get the ID of the post thumbnail ala:

1
<?php echo do_shortcode(&#39;&#91;gallery size="full size" exclude="&#39; . get_post_thumbnail_id( $post->ID ) . &#39;"&#93;&#39;); ?>

2 Responses to WordPress: Excluding Featured Image from Gallery

  1. Hi, I’m looking to do exactly this. Where should the php echo statement be placed? In wp-includes/media.php where the gallery code is generated? Just after the gallery div closes or what?

    Thanks!

    Boax Clothing - Tuesday October 11th, 2011 at 09:44
  2. yes where do we make this edit to?

    lighthouse - Wednesday August 15th, 2012 at 17:43

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>