Exclude featured image from gallery?

So I have some thumbnails but in the main attachment gallery i don’t want the featured image to show.

So far I have implemented this into my functions:
[php]function mdw_exclude_thumbnail_from_gallery($null, $attr) {
if (!$thumbnail_ID = get_post_thumbnail_id())
return $null; // no point carrying on if no thumbnail ID

/* temporarily remove the filter, otherwise endless loop! */
remove_filter('post_gallery', 'mdw_exclude_thumbnail_from_gallery');

/* pop in our excluded thumbnail */
if (!isset($attr['exclude']) || empty($attr['exclude']))
    $attr['exclude'] = array($thumbnail_ID);
elseif (is_array($attr['exclude']))
    $attr['exclude'][] = $thumbnail_ID;

/* now manually invoke the shortcode handler */
$gallery = gallery_shortcode($attr);

/* add the filter back */
add_filter('post_gallery', 'mdw_exclude_thumbnail_from_gallery', 10, 2);

/* return output to the calling instance of gallery_shortcode() */
return $gallery;
add_filter('post_gallery', 'mdw_exclude_thumbnail_from_gallery', 10, 2);


And this into my singlepost
[php]<?php my_attachment_gallery(0, 'large', '[gallery exclude="' . get_post_thumbnail_id( $post->ID ) . '"]', 'alt="' . $post->post_title . '"'); ?>[/php]

However still no avail…

Do you have a live example website I can look at to understand the issue better?

Sponsor our Newsletter | Privacy Policy | Terms of Service