带有自定义字段的条件标记无法正常工作


Conditional Tag With Custom Fields Not working correctly

我想要的是,如果填写了该自定义字段,则在每个日历上显示日期和标题;但目前,它正在将它们按顺序排列并为每个子页面显示一个日历,但我只希望日历和日期在即将到来的日期出现。

任何帮助将不胜感激! - 有关工作示例,请参阅底部的链接。

这是我目前所拥有的:

                <!-- PHP OF OPEN DAYS -->
<!-- Calender Items -->
<div class="calender-item">
<?php $values = get_post_custom_values("next_open_day");
            if ( is_array($values) )
                   the_field( 'university_name');
            else 
    echo '';
 ?>

<?php $values = get_post_custom_values("next_open_day");
            if ( is_array($values) )
                  the_field('next_open_day');
            else 
    echo '';
 ?>
<!-- END OF CALENDER ITEM -->   

</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>

任何想法然后请射走...

我的网站目前吐出它的方式是这样的:

http://universitycompare.net/open-days

将 if 移到div 上方,这样当 false 时它根本不会打印

<?php $values = get_post_custom_values("next_open_day");
            if ( is_array($values) ) {
echo '<div class="calender-item">';
                   the_field( 'university_name');
                  the_field('next_open_day');
echo '</div>';
}
            else 
    echo '';
 ?>