Moraima R.
Member
Posted 1 year ago #
Hello, how can i exclude the secondary featured image i use the following:
<?php echo do_shortcode('[gallery columns="2" exclude="' . get_post_thumbnail_id( $post->ID ) . '"]'); ?>
is the normal way to exclude the main featured image from the gallery.
http://wordpress.org/extend/plugins/multiple-post-thumbnails/
You can use MultiplePostThumbnails::get_post_thumbnail_id('post', 'secondary-thumb', $post_id) to get the post thumbnail ID for the given post type, thumbnail ID, and post ID.
I was able to accomplish this with the following code:
<?php
$featuredA = get_post_thumbnail_id($post->ID); /* first thumbnail */
$featuredB = MultiPostThumbnails::get_post_thumbnail_id('CUSTOM_POST_TYPE', 'SECONDARY_THUMB_NAME', $post->ID); /* second thumbnail */
echo do_shortcode('[gallery exclude="'.$featuredA.','.$featuredB.'"]');
?>