@podkudahka
крутой

Почему у меня некорректно работает infinity scoll?

Почему мой infinity scoll подгружает только первые 2 изображения из каждого album-post? Как сделать чтобы подгружало инфинити скроллом поочередно каждый album-post?
Вот ссылка на страницу
<?php 
        $stati_children = new WP_Query(array(
          'post_type' => 'album-post'
          )
        );
        if($stati_children->have_posts()) :
        while($stati_children->have_posts()): $stati_children->the_post(); ?>
        	<?php 
        	$images = get_field('галерея', get_the_ID());
        	$total = count($images);
        	$count = 0;
        	$galleryNumber = 1;
        	if( $images ): ?>
    	        <?php foreach( $images as $image ): ?>
                	<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
    	        if ($count == $galleryNumber) {
    	            break;
    	        } ?>
    	        <?php $count++; endforeach; ?>
        	<?php else : endif; ?>
        <?php endwhile; endif; wp_reset_query(); ?>
		</div>
		<a id="gallery-show-more" class="load-more-btn" <?php if ($total < $count) { ?> style="display: none;"<?php } ?>>Загрузка…</a>

		<script type="text/javascript">
		    var my_repeater_field_post_id = <?php echo $post->ID; ?>;
		    var my_repeater_field_nonce = '<?php echo wp_create_nonce('my_repeater_field_nonce'); ?>';
		    var my_repeater_ajax_url = '<?php echo admin_url('admin-ajax.php'); ?>';
		    var my_repeater_more = true;
		    var gallery_offset = <?php echo $galleryNumber + 1; ?>;
		    
		    function all_gallery_show_more() {
				jQuery('body').addClass('loading');
		        jQuery.post(
		            my_repeater_ajax_url, {
		                'action': 'all_gallery_show_more',
		                'post_id': my_repeater_field_post_id,
		                'offset': gallery_offset,
		                'nonce': my_repeater_field_nonce
		            },
		            function (json) {
	            		jQuery('body').removeClass('loading');
		                jQuery('.car-park-gallery-wrap').append(json['content']);
		                gallery_offset = json['offset'];
		                if (!json['more']) {
		                    jQuery('#gallery-show-more').css('display', 'none');
		                }
		            },
		            'json'
		        );
		    }
	    </script>

  • Вопрос задан
  • 41 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы