How to Include or Exclude Images From the WordPress Gallery
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:
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:
FREE EBOOK
Your step-by-step roadmap to a profitable web dev business. From landing more clients to scaling like crazy.
FREE EBOOK
Plan, build, and launch your next WP site without a hitch. Our checklist makes the process easy and repeatable.
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.
Tags: