Include and exclude images from a gallery without plugins

One of the shortcomings that we drag on the WordPress galleries is the inability to insert part of the uploaded images, including or excluding elements of it, or separate the gallery into several parts.

We have already seen how do it with plugins like Nextgen Gallery or Multiple Galleries but there is a way to do it just modifying the shortcode of the same native WordPress gallery.

There is only one drawback, and that is that you can not do it with the order identifier that you put on the images you upload in an entry but with the unique identifier of the attachment, I mean …

Imagine you want to create an entry where you want to show several galleries. Of course, you can do it from the image loader, and then add the shortcode de rigueur:
gallery

What happens is that to exclude images with this method you have to edit the image to see the attachment ID of the same (in no other site shows it to you) and you have to do it from the Multimedia Library, to see the ID in the URL. That is, the sequence would be this:

  1. You upload the images from the imager of the entry in question
  2. Once you upload you access the Multimedia Library and click on the link to edit each image and write down the ID of each one in the URL, or you look at the status bar with the cursor over this link, which also shows you the ID of the attachment.
  3. Add to your entry the shortcode including or excluding images from the gallery

Limitations of this method:

  • You can not put in one shortcode an include and an exclude, only one at a time
  • ] The peñazo that is if you use it habitually

Examples:
gallery include = "8812,8813,8814"

gallery exclude = "8815,8816"

In the above example, if you uploaded the attachments from 8812 to 8816, the result you would get would be exactly the same.

gallery include = "8812,8813,8814"

gallery include = "8815,8816"

In this other example, you have divided the gallery into 2 galleries, one with 3 images and the other with just 2.

Anyway, it's a shame that this is not the case It can be done with the ID assigned to the image loader of the editor, or that the gallery system is not improved to include a simple box to choose which images to load in each gallery, but for the moment we have another option available, without plugins.

Note: this trick is the same for hosted WordPress as for WordPress.com, as you can see in these screenshots …

Note 2: This system has also been applied in this post, showing a separate gallery in 2 parts ]
Note 3: In the shortcodes I removed the closing opening brackets that, of course, you must add ([])

NOTICE : this post is two years or more If it's a code or a plugin it might not work in the latest versions of WordPress, and if it's a news story it might be obsolete. Then do not say we have not warned you.

Loading …

That may also help you:

Problems with WordPress 2.8

Well it's going to be the first time I do not recommend updating WordPress, and that version 2.8 is showing some inconsistencies especially in updates.

As you know, I have trying WordPress 2.8 from the first development version, and I have to say that in new installations it is not giving me any problem, but the thing changes in updates. I do not know if it will be from the updater or something that has been introduced in the final version.

In the WordPress Forum we have enabled a thread to expose problems detected which, of course, You can also comment here. Also on the official support forums they have a FAQ for problems with WordPress 2.8 . If you want to be up to date with no problems, just now it is safest to continue with WordPress 2.7.1 which you can download here .

Having seen these problems, right now I do not recommend upgrading to WordPress 2.8 it's almost better to wait for version 2.8.1 where I'm sure these specific but annoying problems will be fixed. And yes, it does not happen to everyone, but remember that a web is like a computer many variables affect it.