0

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. https://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?

3
  • are you sure that the image what you want to exclude has id 93? Commented Jun 8, 2012 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
    Commented Jun 8, 2012 at 11:41
  • yep, just checked the database. the entry in the posts table that is my featured image has ID 93.
    – jammypeach
    Commented Jun 8, 2012 at 11:42

1 Answer 1

1

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
1
  • 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
    Commented Jun 10, 2012 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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