Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress If语句循环两次_Wordpress_If Statement_Advanced Custom Fields - Fatal编程技术网

Wordpress If语句循环两次

Wordpress If语句循环两次,wordpress,if-statement,advanced-custom-fields,Wordpress,If Statement,Advanced Custom Fields,我试图得到它,因此,如果字段设置显示上半部分,否则显示一个位置。它在某种程度上起作用,因为它显示的是空的,但它显示了两次,我似乎不明白为什么 <?php if( have_rows('attach_files_multiple') ): while ( have_rows('attach_files_multiple') ) : the_row(); ?> <?php if( get_row_layout() == 'nec

我试图得到它,因此,如果字段设置显示上半部分,否则显示一个位置。它在某种程度上起作用,因为它显示的是空的,但它显示了两次,我似乎不明白为什么

<?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 elseif ( !empty(get_row_layout('neck')) ) : ?>
这里您基本上是说,如果颈部行布局不是空的,请输出下面的布局。所以它输出两次,因为我假设你有一个颈部排

                <?php elseif ( !empty(get_row_layout('neck')) ) : ?>