• Resolved Ojay

    (@ojay)


    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://ww.wp.xz.cn/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://ww.wp.xz.cn/plugins/ajax-load-more/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)

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