How to Exclude an Image from a WordPress Gallery?
How to exclude an image from your gallery? That’s the question I’ve been asking myself a few days ago. Obviously, WordPress doesn’t provide a solution for this action out of the box so I had to get some help. As usual, Google wasn’t shy and came up with a lot of suggestions. First, I tried to hack my functions.php according to this awesome post from the development team at Code Greene. Yes, it worked out quite well but I didn’t like all the hassle … and I kinda fried my functions.php because the provided code was full of HTML entities (you know, & instead of & and the like).
So, I had to look further and I stumbled over a nice little plug-in called Cleaner Gallery. This plug-in mainly takes care of the invalid XHTML that WordPress produces when using the gallery shortcode. Additionally, it provides the user with a few more features not the least of it the ability to exclude or include any images from your gallery. Just install it, take a look at the provided readme.html and there you go. Nice work!

Sorry about the HTML entities in my post about hacking the functions.php file. WordPress like to hack source code to pieces when you make even the tiniest edits anywhere in the post.
Anywho… I’ll check out that plugin you found, and clean up my post. Thanks.
First of all, thank you for providing the code. After I fixed the HTML entities everything worked fine and it would’ve been enough for me. Unfortunately, I have the habit to suggest solutions to other people and while it worked quite well it wasn’t very straight-forward. People without technical knowledge couldn’t use this solution as easily as others do.
Keep up the good work.
I agree, it wasn’t a very end user friendly solution, but it was built as a quick fix for myself. Because I had never seen anything like it anywhere else in my searches, I posted it. But that plugin you suggested looks like a nice plugin for the not-quite-so-tech-savvy blogger. Nice find.
True enough. The good stuff stays hidden somewhere in a repository or not very descriptive plug-in listing. It even took me a while to find your post. Looks like Cleaner Gallery has been around for a time now but the ability to exclude/include images has only been added recently.
Anyway, I never meant to rant so much. Your code works and that’s all one could wish for.
hello,
Thank you for the great quality of your blog, every time i come here, i’m amazed.
black hattitude
Great blog. Can’t wait to start my own blog.reciprocal link checker
I use to ready our articles and that’s greatn !!!
You are welcome!
Terrible, terrible post. You’re not providing any help at all.
Go look over there and there you go.
Yes, i read the readme.html. This post is a ‘dooie mus’.
To get an attachment ID for an image, go to your Media Library and hover over the image title you want to exclude. You can find the ID in the browser statusbar URL (the number after
attachment_id=).Examples:
[gallery exclude=”24,30,43”]
Works for default