WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to display multiple galleries all at once.

something kind of like this

[gallery id=234,352,832]

The images will be sorted by most recent uploaded shown first.

Is that type of thing possible?

I'd love to do it without a plugin if possible.

share|improve this question
"I'd love to do it without a plugin" why? – chrisguitarguy Dec 18 '11 at 7:52
I had a ton of plugins a while back and they really started to slow down the site so i'm trying to limit the amount I use to a minimum. – Talon Dec 18 '11 at 19:37
up vote 1 down vote accepted

The built in [gallery] shortcode doesn't support that out of the box. However, it's pretty easy to roll your own "multi-gallery" shortcode like so:

add_action( 'init', 'wpse36779_add_shortcode' );
 * Adds the shortcode
 * @ uses add_shortcode
function wpse36779_add_shortcode()
    add_shortcode( 'multigallery', 'wpse36779_shortcode_cb' );

 * The shortcode callback function
 * @ uses do_shortcode
function wpse36779_shortcode_cb( $atts )
    $atts = shortcode_atts(
            'id' => false

    if( ! $atts['id'] )
        // no list of ids? Just send back a gallery
        return do_shortcode( '[gallery]' );
        $ids = array_map( 'trim', explode( ',', $atts['id'] ) );
        $out = '';
        foreach( $ids as $id )
            if( $id )
                $out .= do_shortcode( sprintf( '[gallery id="%s"]', absint( $id ) ) );
    return $out;

And of course, despite your best efforts to not use a plugin, here is that mess as a plugin. You could drop that code, minus the plugin header, in your theme's functions.php file if you really really really don't want to use a plugin.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.