Wordpress uses the gallery-shortcode to insert images, but either you show all the images attached to the post, or you have to pick them by entering their IDs, which is really a pain. Inserting pictures one by one isn’t really an option neither, since WordPress inserts hardcoded links directly in your blog-post-text — whenever you change something in the media-library those changes won’t be reflected in your post!
So I wrote a small plugin, that enables you to use the native WordPress-gallery in a more efficient way, by allowing you to split the gallery into smaller parts.
- easily split your galleries
- show only images of a certain filetype
- set default-values in settings
- uses native WordPress-gallery (no additional code)
Version 0.5 | Download from WordPress
To show just the first 3 pictures of your gallery just insert:
The show-attribute allows more complex notation:
There’s even another way to filter the pictures shown in your gallery — by filetype:
With the exception of ‘include’ and ‘exclude’ all other attributes of the original WordPress-gallery-shortcode are preserved.
[split_gallery id="2144" show="4-6" order="DESC" orderby="ID" size="medium" icontag="span" link="file"]
The plugin-settings-page allows default-values to be defined for the gallery-shorcode attributes. E.g. if you prefer your gallery-links to link to the image-file instead of its permalink, you can set default value for link=”file” and all split_gallery-shortcodes will behave just like you had set each’s option link=”file”.
How it works
The final output is generated by the originial WordPress-gallery — my plugin just translates ‘show’ and ‘filetype’ into a list of IDs for the gallery-shortcode to use. So if you enter the following shortcode
[split_gallery show='1-3' orderby='title']
my plugin gets the IDs of the first 3 images attached to the current post or page. Lets assume there’s a default-setting for link=”file”. Then my plugin inserts this attribute as well and finally calls:
[gallery include='234,213,239' orderby='title' link='file']
where 234, 213 and 239 are the IDs of the first 3 pictures of the gallery.