Skip to content

Instantly share code, notes, and snippets.

@kachi
Created June 11, 2012 15:20
Show Gist options
  • Save kachi/2910617 to your computer and use it in GitHub Desktop.
Save kachi/2910617 to your computer and use it in GitHub Desktop.
<?php
function exclude_thumbnail_from_gallery($null, $attr)
{
if (!$thumbnail_ID = get_post_thumbnail_id())
return $null;
remove_filter('post_gallery', 'exclude_thumbnail_from_gallery');
if (!isset($attr['exclude']) || empty($attr['exclude']))
$attr['exclude'] = array($thumbnail_ID);
elseif (is_array($attr['exclude']))
$attr['exclude'][] = $thumbnail_ID;
$gallery = gallery_shortcode($attr);
add_filter('post_gallery', 'exclude_thumbnail_from_gallery', 10, 2);
return $gallery;
}
add_filter('post_gallery', 'exclude_thumbnail_from_gallery', 10, 2);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment