If you’ve ever added the Gallery to one of your WordPress Posts, you might have had the frustration of keeping the other images in that same Post from appearing in the Gallery. This can come up if your WordPress theme supports Featured Images. It can also come up when you want to include other images in your Post but want to exclude those from the Gallery.
First of all, the fix isn’t about installing a plugin. At least I didn’t find a plugin that handled this without radically changing the nature of the Gallery. The solution is a tiny bit of code I found out about at WordPress support. (I was surprised that the forums were not very good at answering this question.)
Here is what you need to do:
With the Gallery already added to your post, go into your Post Editor. You want to edit the post containing the Gallery.
Click the tab to view the post in HTML.
Scroll to the area where you see the code for the gallery. If you’re not used to reading HTML, get over it. It’s not real code. Think of HTML as a dumb word processor. It’s so dumb you have to code how to <bold>bold</bold> a word. Now scroll down the HTML and find the tag:
This is where you’re going to add a your exclude code. (cough) I mean HTML tag.
Now, before you can do this, you need to know what the ID# is for the image you want to exclude. To find this out, just Preview your article. Then click on the image in the Gallery that you want to exclude. Look up in your browser’s URL location bar you’ll see the URL for that image. The end of the URL shows the ID#. Copy that number.
UPDATE: I was recently coming back to a project that required me to edit out a couple of the images. But rolling over the images in Preview didn’t give me the ID# because I had renamed/titled the images. To get your image ID# go to your Media Library. Then find the image you want. Just roll over it. You will see in your status bar (at the bottom of your browser) the ID# appears. Make sure you have Show Status Bar enabled on your browser. (if that’s an option for you).
Return to your Editor and HTML.
The syntax for excluding an image from your Gallery is:
*If you want to exclude more than one number use commas to separate like this (shown with sample numbers):
Here is what the finished code for excluding one image from the Gallery looks like :
In the above case the image with the ID# of 1134 was excluded from the Gallery on my article about making paper boats. That was the image I only wanted to use as the Featured Image. Notice that image is NOT in the Gallery.
UPDATE: On one of my projects I needed the Gallery short code to perform 2 tasks. 1. Eliminate the unwanted image IDs. 2. link to the image file…as in…just show me the image at full size when I click on it. This was accomplished with the following syntax:
So when I put this to work for me, this is what my code looked like:
Here is the page that this was done on: http://www.bladetechs.com/about-bladetechs/