If you want to display the *attached* image gallery, from another post, you can use: [gallery id="123"] where the custom `id` attribute is the post ID. (no need for custom stuff ;-) Previous answer: ---------------- If you want to display the *attached* image gallery, from another post, you can use: [gallery pid="123"] where the custom `pid` attribute is the post ID. This attribute is supported by the following plugin: <?php /** * Plugin Name: Gallery Shortcode with a post ID. * Description: Support the post ID attribute (pid) in the gallery shortcode * Plugin URI: http://wordpress.stackexchange.com/a/176937/26350 */ add_filter( 'post_gallery', function ( $output, $attr, $instance ) { if( isset( $attr['pid'] ) ) { global $post; $tmp = $post; $post = get_post( $attr['pid'] ); unset( $attr['pid'] ); $output = gallery_shortcode( $attr ); $post = $tmp; } return $output; }, 10, 3 ); Note that you will not be able to order this gallery by hand with drag & drop, since it doesn't contain any explicit image ids. But you can use the `order` and `orderby` attributes instead, for example: [gallery pid="123" orderby="date" order="desc"]