I did a gallery pagination by converting all the stuff from galleries into arrays, and then json_encoding that and passing it to javascript.
If you were to to that you could have multiple scripts:
jQuery(document).ready(function( $ ) {
var thisgallery = <?php echo the gallery; ?>
function process pagination (){
code for pagination
}
}
And because they are all in separate jquery document ready functions they wouldn’t see each other, so they would iterate independently and without page reloads.
Edit:
The modified shortcode function would look like this:
<?php
function picture_gallery($atts){
extract(shortcode_atts(array(
'rml_folder' => 1
), $atts));
query_posts("post_status=inherit&post_type=attachment&rml_folder=".$rml_folder."&orderby=title&order=asc&posts_per_page=-1");
$return_string = "";
$pics = array();
if ( have_posts() ) :
while ( have_posts() ) : the_post();
$p = array(
'image' => wp_get_attachment_image(get_post_thumbnail_id($post->ID), 'medium'),
'url' => wp_get_attachment_url($post->ID)
);
$pics[] = $p;
endwhile;
endif;
$pics = json_encode($pics);
$return_string .= "<div class="js-gallery-$rml_folder"></div>
<script>
jQuery(document).ready(function( $ ) {
var pics = $pics;
console.log(pics);
$('.js-gallery-$rml_folder').html(pics[0][image]);
}
</script>"
wp_reset_query();
return $return_string;
}
Edit: added a div to show the first picture in gallery.