I am Hack Sparrow
Captain of the Internets.

WordPress: How to remove photo from gallery without deleting the image

Remove photo from image gallery in WordPress

WordPress has a very nifty feature - it creates a gallery out of all the images uploaded for a particular post. The gallery can be included in the post with the use of the gallery shortcode.

By default, the gallery will include all the images that were uploaded for the post. Now what do you do if you want to remove some photos from the gallery? You exclude them from the gallery by using the exclude parameter. Eg:

[gallery exclude="176,535,2394"]

To get the ids of the images, go to Media > Library, open the images and get their ids from the attachment_id from their URLs. You can also hover over the links and get the ids from the status bar.


  1. Wordoress gallery shortcode
  2. WordPress shortcode API

Make a Comment