Support

Account

Home Forums General Issues Getting an if else to work Reply To: Getting an if else to work

  • See if this helps

    <?php
    if(have_rows('school_life_holder')) {     
                                
         // add a counter
         $count = 0;
         $group = 0;
    
         while ( have_rows('school_life_holder')) {
            the_row();
    
            if ($count % 3 == 0) {
                 $group++; ?>
    
                <div id="<?php echo $group; ?>" class="row group-<?php echo $group; ?>" data-equalizer> <!--Begin Row:-->
    
                <?php 
             } // count
    
            if( get_row_layout() == 'school-life-link' ) { ?>
    
            <div class="large-4 medium-4 columns panel" data-aos="fade-up" data-aos-delay="150">                        
            
            <div><a href="<?php echo the_sub_field('link'); ?>" target="_blank"><img src="<?php echo the_sub_field("staff_pic") ?>" alt="<?php the_title(); ?>"></a></div>
            
            <div class="profile-box"><a href="<?php echo the_sub_field('link'); ?>" target="_blank"><strong><?php echo the_sub_field('staff_title'); ?></strong></a></div>
            
            </div>
    
            <?php
            
            } // end get link
    
            elseif( get_row_layout() == 'school-life-video' ) { ?>
    
    <div class="video-parent">
    
        <div><a href="<?php echo the_sub_field('link'); ?>" target="_blank"><img src="<?php echo the_sub_field("staff_pic") ?>" alt="<?php the_title(); ?>"></a></div>
                                
        <div class="video-inner">
        <a href="<?php echo the_sub_field('link'); ?>" target="_blank"><img class="bounce_button" src="#"></a>
        </div>
    </div>
    
    <div class="profile-box"><a href="<?php echo the_sub_field('link'); ?>" target="_blank"><strong><?php echo the_sub_field('staff_title'); ?></strong><br><?php echo the_sub_field('staff_job'); ?></a></div>
    
            <?php
    
            } //end get video
    
    if ($count % 3 == 0) { 
    
        echo '</div>'; //----I've moved this outside the previous if statement. Is it suppose to close off the starting if div?.
            }
    
                } //end while
    
    } //if have rows
    
    ?>