I would like to attach an image gallery to a post. Here how i am trying to do it:

  • from the posts administration page i click on: add new media -> create gallery
  • Select the images and click to: create new gallery

After that i dont have a button: "Save gallery", i have just "insert gallery", but this add the shortcode to the content of my post.

I would like to include the gallery like an "object" in my template using wordpress API.

If i remove the shortcode from the post content i loose completely my gallery...

Is there a way so?

  • I'm unclear on what you're trying to do. The gallery will show as a big yellow 'object' in the editor if you switch to 'Visual' - it shows as a shortcode in 'Text' mode. If you're trying to insert the gallery in a Page Template, that's totally different....?
    – Michelle
    Oct 21, 2013 at 15:54
  • @Michelle i dont want to use shortcode mode to include the gallery...i would like to use(if possible) the gallery as a post attached object and call it in the temlate file in the way i could get the urls of single images and style the template as i want...hope it's clear now Oct 21, 2013 at 15:58
  • Gotcha - see @s_ha_dum's answer below, it's the way to go.
    – Michelle
    Oct 21, 2013 at 16:21

1 Answer 1


The gallery is the shortcode. It is not, so far as I know, saved in any other place or in any other way than in that shortcode.

You can print/process shortcodes anywhere you want with tricks like this:

echo do_shortcode('[gallery option1="value1"]');

Or this:

$gallery_shortcode = '[gallery id="' . intval( $post->post_parent ) . '"]';
print apply_filters( 'the_content', $gallery_shortcode );

Both from the Codex.

You can see in the source how that gallery is constructed. It is actually parsed from the values passed in the shortcode.

If you need to save that shortcode and retrieve it some other way you will need to construct your own mechanism for doing so.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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