Some doubts about gallery shortcode in WordPress

If you want to display the attached image gallery, from another post, you can use:


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:


Leave a Comment