Friday, March 11, 2011

Exclude Images From WordPress Gallery Display

I wrote this post yesterday which had several images as part of the content. One image was used in a different section of the post, but I wanted to group specific images together to highlight a point I was making.

WordPress adds all images uploaded during post creation to a Gallery. Once all the images have been uploaded, you can select the Gallery tab, and insert the gallery right into the post. However, I wanted to exclude one of the images. But there wasn't anything in the image manager that allowed me to exclude an image. (WordPress guys, please add this feature.)

No worries though, the WordPress Gallery is really short code, and the short code allows for parameters. In this case, I was able to add the exclude parameter with the ID of the image I didn't want in the Gallery, and whala, I was able to display what I wanted. You can get the ID of the image in the Library and hover over the image, you should see a value for attachment_id, make note of it. The short code lookes like this:

[ gallery exclude="123" ]
Share this article

0 comments:

Post a Comment

 
Copyright © 2003 - 2014 Thom Allen Weblog • All Rights Reserved.