I'm having trouble removing the featured image from gallery.
I removed all kinds of stuff from those 2 files, but seems like I need to add something, not take away. Here are the pastebin's of 2 files:
I'm having trouble removing the featured image from gallery.
I removed all kinds of stuff from those 2 files, but seems like I need to add something, not take away. Here are the pastebin's of 2 files:
Assuming that you are using the standard functionality of the gallery:
[gallery ids = "1,2,3,4,5,6,7,8"]
You can extract the id of the images without having to do a query for attachments of that post with:
preg_match('/\[gallery.*ids=.(.*).\]/', get_the_content(), $ids);
Then make an array of these values:
$ids = explode( ',' $ids[1] );
Eventually check if the id of the featured image exists and get its position( i think that it doesn't exists till you don't place it inside the gallery ):
$pos = array_search( get_post_thumbnail_id( get_the_ID ), $ids);
unset that value:
unset($ids[$pos]);
now you have all the attachments ids, less the one of featured image stored in $ids array.
UPDATE
<?php
//// GETS OUR IMAGES
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' =>'image',
'post_status' => 'inherit',
'posts_per_page' => -1,
'post_parent' => get_the_ID(),
'exclude' => get_post_thumbnail_id(),
'orderby' => 'menu_order',
'order' => 'ASC',
);
$images = get_posts( $query_images_args );
?>
<div class="sidebar-item not-in-responsive">
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#property-gallery-thumbs').propertyGallery();
});
</script>
<ul id="property-gallery-thumbs">
<?php
$i = 1;
/// IF WE HAVE MORE THAN JUST ONE IMAGE
if( $images ) : foreach( $images as $image ) : setup_postdata( $image ); ++$i;
?>
<li class="thumb<?php if($i==1) { echo ' current'; } ?><?php if($i%3 == 0) { echo ' last'; } ?>">
<span class="hidden full"><?php echo wp_get_attachment_url( $image->ID ); ?></span>
<span class="hidden main"><?php echo ddTimthumb(wp_get_attachment_url( $image->ID ), 680, 450); ?></span>
<span class="thumb"><img src="<?php echo ddTimthumb(wp_get_attachment_url( $image->ID ), 76, 76); ?>" alt="<?php the_title() ?>" title="<?php the_title(); ?>" /></span>
</li>
<?php endforeach; wp_reset_postdata(); ?>
</ul>
<!-- /#property-gallery-thumbs/ -->
</div>
<?php endif; ?>
shortcode_atts_gallery
filter introduced in WP 3.6. It allows to change all attributes – and therefore the passed IDs – without much hassle. See: markjaquith.wordpress.com/2013/04/04/… and github.com/WordPress/WordPress/blob/master/wp-includes/…