I am using wordpress gallery shortcode I was wondering if there is anyway to paginate them without using a plugin.
Leave a Reply
You must be logged in to post a comment.
I am using wordpress gallery shortcode I was wondering if there is anyway to paginate them without using a plugin.
You must be logged in to post a comment.
I’ve written answer to How to paginate attachments in a secondary query as gallery?, which can be used for solving this problem. Like @wpmudev-ari said the [gallery] shortcode can be rewritten, or a new shortcode could be created. I explain below – B. – how this can be done. Additionally there is a very simple solution – A. – for the pagination of the shortcode.
A. Simple solution for paginating [gallery] shortcode
You can achieve pagination by using:
numberposts
andoffset
arguments of the shortcode;<!--nextpage-->
tag;like shown below.
Code:
This actually doesn’t paginate the gallery, it paginates the post containing the gallery – or to be exact the splited gallery. But in some use cases this might just be enough, see the source for more details.
Source: Quick Tip: Paginate Your WordPress Gallery
B. Paginated by rewriting [gallery] or creating new shortcode
This assumes you want something like this:
1. Rewriting the [gallery] shortcode
a)
Code:
b)
Code:
2. Creating a new shortcode
Code:
3. Shortcode function
Code:
4. Additional code
a) Add a query variable
Code:
b) Rewrite
Code: