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.
If you want limit the number of items in a gallery, there seems to be a plugin available on wordpress.org called Limit parameter for gallery shortcode (no affiliation). It uses the pre_get_posts
filter to change the posts_per_page
and offset
attributes of the get_posts()
or get_children()
calls in the gallery shortcode callback.
Example:
[gallery id="4" limit="3" offset="1"]