我試圖在WordPress中使用高級自定義字段顯示3個不同位置的商店時間。當我用else if聲明取出整個中間部分時,它對另外兩個位置正常工作。只要我用else if語句添加部分,商店的小時數對於所有頁面都是空白的。任何幫助將不勝感激。以下是我迄今爲止:高級自定義字段其他如果
第一節
<?php if (is_single(3823)){ ?>
<section class="hours">
<h3>Outlet Hours:</h3>
<section class="hours-section">
<?php if(get_field('store_hours')): ?>
<?php while(has_sub_field('store_hours')): ?>
<p class="days"><b><?php the_sub_field('store_hours_day'); ?>: </b></p>
<?php if (get_sub_field('store_hours_closed') == "open") { ?>
<p class="hours-hours">
<?php the_sub_field('store_hours_morning_time'); ?> am
-
<?php the_sub_field('store_hours_evening_time'); ?> pm
</p>
<?php } ?>
<?php if (get_sub_field('store_hours_closed') == "closed") { ?>
<b>Closed</b>
<?php } ?>
<br/>
<?php endwhile; ?>
<?php endif; ?>
</section>
</section><!-- .sidebar -->
第二部
<?php else if (is_single(2284)){ ?>
<section class="hours">
<h3>Builder Hours:</h3>
<section class="hours-section">
<?php if(get_field('store_hours')): ?>
<?php while(has_sub_field('store_hours')): ?>
<p class="days"><b><?php the_sub_field('store_hours_day'); ?>: </b></p>
<?php if (get_sub_field('store_hours_closed') == "open") { ?>
<p class="hours-hours">
<?php the_sub_field('store_hours_morning_time'); ?> am
-
<?php the_sub_field('store_hours_evening_time'); ?> pm
</p>
<?php } ?>
<?php if (get_sub_field('store_hours_closed') == "closed") { ?>
<b>Closed</b>
<?php } ?>
<br/>
<?php endwhile; ?>
<?php endif; ?>
</section>
</section><!-- .sidebar -->
三節
<?php }
else { ?>
<?php $other_page = 47; ?>
<section class="hours">
<h3>Retail Hours:</h3>
<section class="hours-section">
<?php if(get_field('store_hours', $other_page)): ?>
<?php while(has_sub_field('store_hours', $other_page)): ?>
<p class="days"><b><?php the_sub_field('store_hours_day', $other_page); ?>: </b></p>
<?php if (get_sub_field('store_hours_closed', $other_page) == "open") { ?>
<p class="hours-hours">
<?php the_sub_field('store_hours_morning_time', $other_page); ?> am
-
<?php the_sub_field('store_hours_evening_time', $other_page); ?> pm
</p>
<?php } ?>
<?php if (get_sub_field('store_hours_closed', $other_page) == "closed") { ?>
Closed
<?php } ?>
<br/>
<?php endwhile; ?>
<?php endif; ?>
</section>
</section><!-- .sidebar -->
是您的 「營業時間」 ACF領域的 「轉發」 字段? – Kory