Create a native WordPress gallery using any post type’s images

Did you know ever wanted to have a on a page a gallery of some post’s images? Or maybe on a post, a gallery of some other post type’s images.

Yeah, me too.

It so happens that you can, without any plugins and the such.

The [gallery] shortcode accepts an id parameter (among others) that allows you to pass the post’s ID number to get the images from. So, for example:
[gallery id="123"]
will create a gallery taking the attached images of the post that has ID 123. It doesn’t matter if post 123 is a post, page, or a custom post type. They are all the same to WordPress.

Gotta love WP :)

2 comments

  1. Ingvar Aandalen says:

    How can I give a name (of the gallery) parameter to the gallery short code?

    1. Anastis Sourgoutsidis says:

      This isn’t possible with the current implementation of the gallery shortcode. Only IDs are supported.

Leave a Reply

Your email address will not be published. Required fields are marked *