wordpress - If statement looping twice -
im trying if field set show top half else show placement. works degree in fact shows empty, showing twice , cant seem figure out why
<?php if( have_rows('attach_files_multiple') ): while ( have_rows('attach_files_multiple') ) : the_row(); ?> <?php if( get_row_layout() == 'neck' ) : ?> <div class="media"> <div class="media-left media-middle"> <!-- image start --> <?php $image = get_sub_field('preview_prop_neck'); if( !empty($image) ): ?> <img class="media-object" width="100px" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> <?php endif; ?> <!-- image end --> </div> <div class="media-body"> <?php $file = get_sub_field('prop_file_neck'); ?> <h4 class="media-heading"> neck piece <a href="<?php echo $file['url']; ?>" class="pull-right btn btn-primary"><i class="fa fa-download"></i> download</a> </h4> </div> </div> <?php elseif ( !empty(get_row_layout('neck')) ) : ?> <div class="overlay"><h3>helmet - no file found</h3></div> <div class="media"> <div class="media-left media-middle"> <!-- image start --> <img class="media-object" width="100px" src="<?php bloginfo('template_directory'); ?>/images/pdo.png"> <!-- image end --> </div> <div class="media-body"> <h4 class="media-heading"> neck piece <a href="#" class="pull-right btn btn-primary"><i class="fa fa-download"></i> download</a> </h4> </div> </div> <?php endif; ?> <?php endwhile; ?> <!-- end while ( have_rows( ) --> <?php endif; ?> <!-- end if( have_rows ) ?> -->
<?php if( get_row_layout() == 'neck' ) : ?>
here saying "if neck row layout exists, output layout below".
<?php elseif ( !empty(get_row_layout('neck')) ) : ?>
here saying "if neck row layout not empty, output layout below". it's outputting twice because i'm assuming have neck row.
Comments
Post a Comment