Top

Daily Tip: How to Include or Exclude Images From the WordPress Gallery

October 2, 2011

There are many ways that you can customize the native WordPress gallery shortcode. If you just use the gallery shortcode by itself, the default behavior is to include all of the images attached to a post.

But what if you want to limit the gallery to only a few specific images? For example, let’s say you want to show a small gallery of food pictures?

Here’s a couple quick ways to customize the WordPress gallery shortcode.

How to Exclude Specific Images:

If you want to include all images attached to a post, with the exception of a select few, you can use “exclude=” in the shortcode, followed by comma separated attachment IDs:

[gallery exclude=”123,39,45″]

How to Include Specific Images:

If you want to include only a few specific images, then you will want to use the “include=” option in the gallery shortcode, followed by comma separated attachment IDs:

[gallery include=”123,39,45″]

Important Note: You cannot use the “include=” and the “exclude=” together. Select one or the other for the most efficient way to show the exact photos that you want to display.

For more information make sure to check out the Gallery Shortcode page on the WordPress codex.

Comments

Got something to say?

Bottom
Article Archive  |  This site is a historical archive of pressography.com, a WordPress plugin and theme blog that published between 2006 and 2012. It is preserved for reference and is not operated by, affiliated with, or endorsed by its original authors. Nothing here is for sale and no form on this site is active. If you are the original owner and would like this domain returned, please get in touch.