Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using this bit of code on single.php:

$params='[gallery link="file" size="my_thumbnail_small" exclude="'.$featuredId.'"]';
$gallery = do_shortcode($params);
echo $gallery;

But nomatter what I put in the exclude param, it has absolutely no effect on the output, the image that I'm trying to exclude gets shown every time regardless of the params I use.

My $featuredId var contains the ID of the post thumbnail / featured image, which in this test case is 93. I've tried just with exclude="93" incase it's getting overwritten or something but to no avail.

The theme is an almost completely blank one with nothing but a few add_image_size() calls in functions.php and the only plugins I'm currently using is file un-attach 1.01. Wordpress is at version 3.3.2.

Anyone have any idea why this isn't doing what I expect?

EDIT: I've tried the accepted answer from this question on SO, still no dice. http://stackoverflow.com/questions/4337999/wordpress-exclude-the-post-thumbnail-from-gallery-shortcode

Maybe there is some theme support I need to add for this to work?

share|improve this question
    
are you sure that the image what you want to exclude has id 93? –  Eugene Manuilov Jun 8 '12 at 11:34
    
not completely, could be wrong. How I find the id is like this: $featuredId=get_post_thumbnail_id();. When I echo that I get 93. But now you've said that, I'm going to see if I can find out if that's right –  jammypeach Jun 8 '12 at 11:41
    
yep, just checked the database. the entry in the posts table that is my featured image has ID 93. –  jammypeach Jun 8 '12 at 11:42
add comment

1 Answer

up vote 1 down vote accepted

You say "regardless of the params I use"...

You're not using the include at the same time, are you?

Troubleshooting ideas:

  • use only [gallery exclude="93"]
  • remove it from the Featured Image
  • put the shortcode in the post content
share|improve this answer
    
good suggestions but didn't help. I wasn't using include at all, just what I posted. I think something was not quite right with that particular theme or install of WP, because I tried this on another WP site and it worked as expected. Havent figured out what went wrong though. –  jammypeach Jun 10 '12 at 1:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.