• So, I’m using a ACF content repeater as a template on ALM, and I want it to stop at 8 items, but $alm_item is always 1. I’ve tried to add $alm_loop_count and defining $alm_item as 0 and then $alm_item++, but all I’m getting now is an internal server error on the console.

    template repeater I’m using:

    <?php $alm_loop_count = 0; $alm_page_count = 0; (have_rows('work_gallery')): ?>
          <?php while (have_rows('work_gallery')):
    		the_row();
    		$alm_loop_count++;
    		if ($alm_loop_count > 8)
            {
            	$alm_page_count++;
            	$alm_loop_count = 0
            }
    		var_dump($alm_loop_count);
    		var_dump($alm_page_count);
    			?>
    
            <div class="col-xs-12 col-sm-6 gallery-item tag-all <?php
                  $tags = get_sub_field('tags');
                  if( $tags ) {
                    foreach($tags as $t) {
                      $t = get_category($t);
                      echo 'tag-'.$t->name.' ';
                    }
                  }
                ?>" style="background-image:url('<?php echo the_sub_field('image'); ?>');">
              <div class="client-logo">
                  <img class="img-responsive" src="<?php echo bloginfo('template_url');?>/images/<?php echo the_sub_field('client_logo');?>" alt="<?php echo the_sub_field('client'); ?>">
              </div>
              <div class="tags">
                <ul>
                <?php
                  $tags = get_sub_field('tags');
                  if( $tags ) {
                    foreach($tags as $t) {
                      $t = get_category($t);
                      echo '<li>'.$t->name.'</li>';
                    }
                  }
                ?>
                </ul>
              </div>
              <h2>
                <?php echo the_sub_field('title'); ?>
              </h2>
              <a href="<?php echo the_sub_field('link'); ?>" class="btn btn-reverse">View Work</a>
            </div>
          <?php endwhile; ?>
        <?php endif; ?>

    And on the page-template:

    <?php echo do_shortcode('[ajax_load_more post_type="page" post_format="standard" posts_per_page="8" scroll="false" transition="fade" button_label="see more work" button_loading_label="Loading..."]' ); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ricardocrab

    (@ricardocrab)

    The previous code had an error in it. Now I’m no longer getting an internal server error, but the ALM keeps on loading content past $alm_loop_count = 8 and $alm_page_count = 2:

    <?php $alm_loop_count = 0; $alm_page_count = 0; if (have_rows('work_gallery')): ?>
          <?php while (have_rows('work_gallery')):
    		the_row();	?>
    
            <div class="col-xs-12 col-sm-6 gallery-item tag-all <?php
                  $tags = get_sub_field('tags');
                  if( $tags ) {
                    foreach($tags as $t) {
                      $t = get_category($t);
                      echo 'tag-'.$t->name.' ';
                    }
                  }
                ?>" style="background-image:url('<?php echo the_sub_field('image'); ?>');">
            <?php
            	$alm_loop_count++;
    if ($alm_loop_count > 8)
    {
    $alm_page_count++;
    $alm_loop_count = 0;
    }
    		var_dump($alm_loop_count);
    		var_dump($alm_page_count);
            ?>
              <div class="client-logo">
                  <img class="img-responsive" src="<?php echo bloginfo('template_url');?>/images/<?php echo the_sub_field('client_logo');?>" alt="<?php echo the_sub_field('client'); ?>">
              </div>
              <div class="tags">
                <ul>
                <?php
                  $tags = get_sub_field('tags');
                  if( $tags ) {
                    foreach($tags as $t) {
                      $t = get_category($t);
                      echo '<li>'.$t->name.'</li>';
                    }
                  }
                ?>
                </ul>
              </div>
              <h2>
                <?php echo the_sub_field('title'); ?>
              </h2>
              <a href="<?php echo the_sub_field('link'); ?>" class="btn btn-reverse">View Work</a>
            </div>
          <?php endwhile; ?>
        <?php endif; ?>
    Plugin Author Darren Cooney

    (@dcooney)

    Really sorry but im not exactly sure what you are trying to do here.

    You can’t reset $alm_loop_count because it’s set every time the repeater template is included.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘ACF inside ALM not counting loops?’ is closed to new replies.