How to Exclude Photos from a WordPress Gallery

We often use WordPress’s in-built “Gallery” function to display all of the photographs we’ve added to a WordPress post or page.

This is done by adding the Gallery shortcode, into a WordPress post or page (after, of course, having added some pictures to that post!):


Sometimes, though, you don’t want to include all your pictures in your gallery, for example if you’ve already displayed one or two photos above in your post.

For these occasions, you need to do the following:

[gallery exclude="NUMBER"]

Replace NUMBER with the picture ID of the image (or images, comma separated) that you want to filter out of your gallery.

Which leads us to another frequently asked WordPress question!

How to Find Your Image’s ID Number

The quickest way to find your image ID number, in our experience, is to hit the “Upload/Insert” button, and, under the Gallery tab, press “Show” for the image in question. Half way down, you’ll see “Link to” settings, clicking on “Attachment” will display the attachment ID number – this is the number you need – copy and paste. Repeat for as many images as you’d like to filter out!

An Alternative Way?

The above method is ever so slightly long winded. An alternative way, assuming you don’t mind your images not being attached to your post, is to upload them from within your WordPress dashboard, and only upload from within your “post” screen the images you’d like in your gallery (i.e. don’t “attach” the images you don’t want in your gallery to that post).

Please note you can create galleries of specific images, too, using the latest versions of WordPress, though the above method will still work to include all attachment images, minus some specific pics.

Questions or comments? Leave them below!

Leave a comment

No links of any kind allowed in comments - if you add any links, your comment will automatically be deleted.