function all_gallery_show_more() {
// validate the nonce
if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'my_repeater_field_nonce')) {
exit;
}
// make sure we have the other values
if (!isset($_POST['post_id']) || !isset($_POST['offset'])) {
return;
}
$show = 8; // how many more to show
$start = $_POST['offset'];
$end = $start + $show;
$post_id = $_POST['post_id'];
ob_start();
$stati_children = new WP_Query(array(
'post_type' => 'album-post'
)
);
if($stati_children->have_posts()) {
while($stati_children->have_posts()) {
$stati_children->the_post();
$images = get_field('галерея', get_the_ID());
if ($images) {
$total = count($images);
$count = 0;
foreach( $images as $image ) {
if ($count < $start) {
$count++;
continue;
}
?>
<a class="car-park-gallery-wrap__item" data-fancybox="car-park-gallery" href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
</a>
<?php
$count++;
if ($count == $end) {
break;
}
}
}
}
}
$content = ob_get_clean();
$more = false;
if ($total > $count) {
$more = true;
}
// output our 3 values as a json encoded array
echo json_encode(array('content' => $content, 'more' => $more, 'offset' => $end));
exit;
} // end function gallery_show_more