2
votes

I getting error with php endif, couldn't find the error. here I have given my code. please help me to fix this

       <?php if( have_rows('home-video-slider') ): ?>
            <?php while( have_rows('home-video-slider') ): the_row(); 
              $video_banner = get_sub_field('video-banner');
             ?>
             <div class="item">
                <div class="fm-video-banner">
                        <?php if( $video_banner ); ?>
                        <img  src="<?php echo $video_banner['url']; ?>"/>
                        <?php endif; ?>

                    <a class="popup-youtube fm-play-icon" 
                      href="https://www.youtube.com/embed/5ktgB9hlETw">
                        <span>
                            <i class="fa fa-play" aria-hidden="true"></i>
                        </span>
                    </a>
                </div>
            </div>
            <?php $p++; endwhile; ?>
     <?php endif; ?>
1

1 Answers

9
votes

Wrong syntax there :

<?php if( $video_banner ); ?>

To be replaced by

<?php if( $video_banner ): ?>

writting a ; after the condition of a if is like writting

<?php
    if( $video_banner )
    {
        ; //Do nothing
    }
?>

This means you have one endif; in excess