Pagination question: can a Modal with next/previous buttons advance to items on the next page of pagination results?

**Pagination:**
I have pagination going with 4 pages currently.

**Pages:**
On each page are 5 rows of custom post types. I have set the custom posts types to have the option of 1,2, or 3 images. The result is that each page is a little grid portfolio with varying size images.

**Modal:**
Click any one of those images on a page and it will open up a modal for that project. The modal has previous/next navigation so you can get through all the projects on that particular page without leaving the modal.

**Problem:**
The problem I’m having is there are currently 4 pages you can paginate through, but the modal closes after the last item on whatever page you’re on. I would like the modal navigation to be able to access *all* the images in all pages. Is this possible?

If that’s possible, it would allow a person to just keep clicking “next” in the modal and go through all 4 pages worth of items without actually clicking the pagination buttons at the bottom of the page. I feel like as a user experience it’s a little confusing when the user gets to the end and the modal closes. If they don’t notice the pagination at the bottom, they might not bother to click to page 2 and that would mean they only seen 1 page of the portfolio.

**Vague Solution?**
I feel like if I somehow figured out how to run 2 separate queries (one to get 5 CPTs for the pagination, another to get ALL the CPTs for the modal) that could solve the problem. However, the trigger to open the modal is dependent on what is on the page, so I’m not sure how to connect the click event from one query to another query. The other problem with this idea is I think if I load in ALL the CPTs for the modal, it’s going to be a **gigantic** pageload with a slow rendering time.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer