We can all agree that WordPress is a phenomenal application whose ease of use and learning curve is second to none. But sometimes it can be a bit unintuitive and downright clunky when it comes to the user’s experience. Trust me, this is an incredibly rare occurrence and, in my opinion, not indicative of the overall application’s UX.
One of these times occurs with the WordPress Image Gallery insertion. The uploading of media is intuitive. Gallery columns and links are intuitive. Where to inset the gallery is intuitive. But, how about if you want to exclude an image, or images, that appear in the post from the gallery? Ah, not so intuitive. In fact, from the UI, you would think that WordPress does not allow you to exclude images from your gallery, right?
Wrong. WordPress allows you to exclude images from the gallery by passing the ID’s of the images through the exclude
parameter of the shortcode. The only problem is you have to do a little more work to execute the solution.
Step 1: Create you gallery
Create your gallery, with your options, as you normally would and insert your gallery. Save your post because we will need to get the ID’s of the images to exclude and will have to navigate away from the post editor.
Step 2: Get the images ID
There are multiple ways of getting an image’s ID, in WordPress. I find the easiest method is to do the following:
- Click on the Media link in the Admin sidebar.
- Click on the image you would like to get the ID for.
- In your browsers navigation bar, you will see an URL that contains the ID number.
- Repeat for all images ID’s.
Step 3: Edit the gallery shortcode
Now that you have the image ID numbers, head back to the post that contains your gallery. Switch to HTML mode and locate the gallery’s shortcode. Add the exclude command and all of the ID’s separated by commas. The shortcode should now look like this.
That’s it. Hopefully, the developers behind WordPress will come with an easier solution to manage this task in the future. Until then, this is 100% viable, if not slightly more time consuming.