I’m working on a site that will ultimately have dozens of photo galleries, each gallery with at least 3-4 photos, and possibly up to 20. Individual photos won’t have captions, titles or any other metadata; they’re all just pictures that belong in a gallery. (An individual gallery does have a title, description, etc.)
I am not sure how to best set this up in WordPress. I’m using WCK custom fields and I’m comfortable with custom pages, taxonomies, etc. Since the photos don’t have any metadata, it seems like overkill to create a custom page type for photos. But maybe I do that, and then also create a custom page type called “galleries” that lets the user pick which photos belong in the gallery?
Or do I just set up the galleries as a custom page type, and somehow let the user choose multiple photos from the media library to put into the gallery? Then I’m not creating a separate page type for photos, but how would I let the user choose multiple photos from the media library to add to the gallery?
Recently I’m using this workflow:
Use some code to add the feature of mass assign taxonomy terms to uploaded images
(Because I do these 2 tasks frequently I’ve created a plugin that implement them and more see here)
Create in a plugin a shorcode that looks like
[gallery_term tag="landscapes, still_life"]
. This shortcode takes the tag(s) passed as shorcode param and use them in aWP_Query
withmeta_query
to retrieve images and output them.Once done I need only to upload images and assign them a tag for every gallery to which they belongs (using my plugin for bulk assignment it’s a cinch). The create a post (or a page, or a cpt) and use the shortcode. That’s all.
This workflow is absloutely powerful and flexible:
A great piece of my workflow is done by the shortcode function, that is something like this:
This function provide huge flexibility, in fact:
gallery.php
in current theme to output mygallery (using global
$gallery_query
variable). If I want to useanother template I can change it passing name via shortcode param or
via a filter.
any gallery item. The default is
gallery-item.php
but again I canchange it via shortcode or via filter. Using this template the
attachment post is accessible in the global $post variable, so all
template tags works
[gallery_term tag="atag"]
and do not create any template file… it works!