Posted on 12 October, 2010 By 8 Comments

How to Include and Exclude Images with the WordPress Gallery Shortcode

 

Almost a year ago I wrote about how a simple gallery could be added to a post or page using the WordPress Gallery Shortcode. At the time I found out about it because include and exclude were going to be added to later releases. It is now part of the shortcode.

Last week I used the gallery shortcode for the Halloweeen themes post but I didn’t want to use all of the images in the gallery – the photo of the cupcakes is in the gallery associated with that post but I wanted to exclude it because it isn’t an image of a theme.


Using include or exclude looks like the following

[gallery exclude=”21,32,43″]

You can not use include and exclude in the same shortcode – it has to be one of the other. The numbers being exclude are the attachment ID’s for each image that you don’t want to display. When I looked in the gallery, however, for that post I didn’t see any attachment ID’s.

It turns out that you have to get the attachment ID from the media library.

  1. Go to Media > Library
  2. Click on the title of the image that you want to exclude.
  3. The attachment ID will be in the URL in your browser’s address bar. For example, the image include in this post has the URL
    http://www.kimwoodbridge.com/wp-admin/media.php?attachment_id=9633&action=edit The attachment id is 9633.

I typically add images through upload/insert when writing a post and not through the media library. It would be helpful if the attachment id was included in both locations. At any rate, this feature makes the simple image gallery included with WordPress a lot more useful.

photo credit: Schristia




Keep Reading:
Posted In : WordPress Tips

Did you enjoy this article? I can assist you with your WordPress or Facebook project. Contact me and I will provide you with an estimate. You can also connect with me on Facebook or follow me on Twitter. If you are looking for Hosting, WordPress Theme, Newsletter or other recommendations, please view my detailed list.




8 Responses to “How to Include and Exclude Images with the WordPress Gallery Shortcode”

Trackbacks/Pingbacks
  1. Incluir y excluir imágenes de una galería sin plugins | Ayuda WordPress
Leave a Comment
You may use: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .

CommentLuv badge

About

Kim Woodbridge is an accomplished Information and Technical Consultant specializing in the entire implementation of a WordPress based website including installation, theme design, upgrades, unique customizations and ongoing site maintenance.

Recent Comments

    • Property Marbella: Hi Kim, Good article with several good tips, my friend up in Sweden has clothing stores and online sales with little tr...
    • Kim Woodbridge: This post was written 2.5 years ago. At that time people wanted detailed instructions and asked me to write it. And wh...
    • Kim Woodbridge: Pretty much all themes have a page.php file. Are you using a child theme? If so, you will want to look for the page.ph...
    • Mitch: That's why the internet has evolved into a worthless piece of "junk yard". Everybody is repeating the same thing over an...
    • Meredith: This is very straightforward info, and I think it will help, but I have one question. What if I don't have a page.php fi...

Wordpress Services

  • Installation, upgrades and maintenance
  • Conversion of existing html and css templates
  • Theme and plugin recommendations
  • CSS customizations
  • Troubleshooting and tweaks for unique situations
  • Customization for individual blogging goals and needs
  • Training and advice