Title: If Statement &amp; Php Counter
Last modified: August 22, 2016

---

# If Statement & Php Counter

 *  Resolved [Ojay](https://wordpress.org/support/users/ojay/)
 * (@ojay)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/if-statement-php-counter/)
 * Hey there buddy, loving the plugin but it seems to be struggling with when I 
   open & close div tags.
 * I’m just trying to implement a simple php counter and associated if statement.
   I want a div opened on the first of every 4 loops and that same div closed at
   the end of every 4 loops.
 * In my repeater template, if I use the following…
 *     ```
       <?php
       if (!$start) {
       	$start = 1;
       } 
   
       if ($start == 1 || $start == 5 || $start == 9 || $start == 13) {
   
       echo '<div class="row">';
   
       } ?>
       ```
   
 * And at the bottom of the repeater template I have…
 *     ```
       <?php
       if ($start == 4 || $start == 8 || $start == 12 || $start == 16) {
   
           echo '</div>';
        }
   
       $start++;
       ?>'
   
       When I press the Load More Posts button everything works perfectly. When I press it again, nothing. No console errors, just blank. If I place a closing div in that first if statement, and an opening div in that last if statement, then the divs print in the desired place and I can keep clicking the load more button and the posts just keep on loading.
   
       I've no idea, literally no idea, what could be causing this... any help would be much appreciated. I've tried so many different if statements and counter methods.
       I've looked at this post... and had something built based off that, but still the issue remained.
       https://wordpress.org/support/topic/return-the-current-page-number?replies=6
   
       Template code below...
       ```
   
 * <?php
    $features = $feat_ids; // Array of posts if($features){ //Implode the 
   posts and set a varible to pass to our exclude param. $postsNotIn = implode(“,”,
   $features); } global $start; $start = 1;
 *  echo do_shortcode(‘[ajax_load_more posts_per_page=”16″ scroll=”false” pause=”
   true” transition=”fade” exclude=”‘.$postsNotIn.'”]’);
    ?>`
 * [https://wordpress.org/plugins/ajax-load-more/](https://wordpress.org/plugins/ajax-load-more/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Ojay](https://wordpress.org/support/users/ojay/)
 * (@ojay)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/if-statement-php-counter/#post-5514653)
 * Marked as resolved due to duplicate post

Viewing 1 replies (of 1 total)

The topic ‘If Statement & Php Counter’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

## Tags

 * [ajax](https://wordpress.org/support/topic-tag/ajax/)

 * 1 reply
 * 1 participant
 * Last reply from: [Ojay](https://wordpress.org/support/users/ojay/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/if-statement-php-counter/#post-5514653)
 * Status: resolved