I have a multiple-instances image custom field where users can add images for a gallery. Is there any way to create a view/content template with pagination for the custom field values so they would not load all at once?
Thank you, I have tested the plugin and it works. The trouble is that the issue that I have is still there since if you have a relatively large number of images in the gallery, then the page would load slowly. I was thinking to limit the images size and number, but the issue somehow would still be there as I wouldn't limit it too much. So, what I was thinking was to split the custom field array and to display it using some pagination...
Given that you are using a repeatable field then it wouldn't be possible to paginate through them. What would happen is that you will need to load them all at once and use the setup that I sent previously to paginate through them as a gallery.
With Repeatable field groups your are able to paginate through a set of them at a time, but you will need to be uploading the images one at a time, which i suspect would be an undesirable result for you.
What you can do is to leverage the load time with the use of caching so views won't need to hit the database each time this page is loaded.
Just now I thought that since I have only one custom field where I intend to store images/attachments for the gallery post, maybe I could create a view to display the Media attached to the post itself. However, I don't see how to create a proper query for that... Maybe I could use this: https://developer.wordpress.org/reference/functions/wp_get_attachment_url/ ?
if ( 'attachment' != $post->post_type ) {
return false;
}
Maybe adding a shortcode for filtering.. :-?? I will have a look into it tomorrow (it's late here)... until then, maybe you could give me any hint if this should be the way or if I should try something else?
Unfortunately I dont think wordpress has a way of handling this particular issue because you still wouldn't be able to dynamically load your images on request.
There is a pagination setting for wordpress but this only applies to posts and not post meta. Essentially you're not able to pagination through the different items in a custom field.
You will need to load it in its entirety and then paginate through it dynamically on the frontend using the solution that i've previously advised.
Anything outside of this would require some advanced coding and use of SQL queries to get the values from the array of images.
Thank you, Shane.. I spent some time today thinking on this matter. You are right, it can be done only with advanced coding which is out of the scope and beyond my capabilities at the moment. I will look into it some other time. My issue is resolved for now. Thank you!