【发布时间】:2015-10-02 19:10:06
【问题描述】:
我正在尝试获取它,因此如果设置了该字段,则显示上半部分,否则显示一个位置。它在某种程度上有效,事实上它显示了空,但它显示了两次,我似乎无法弄清楚为什么
<?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 ) ?> -->
【问题讨论】:
标签: wordpress if-statement advanced-custom-fields