Created
June 11, 2012 15:20
-
-
Save kachi/2910617 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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