如果else语句不起作用

时间:2016-02-20 14:01:37

标签: php wordpress if-statement

我正在使用Meta Box Plugin

我在Post Edit中有两个选项。一个添加徽标,一个添加标题。在前端(在我的模板中)我想要显示徽标或标题,但不是两者。 我将此代码添加到我的模板中,但它无法正常工作:

<?php if( rwmb_meta('restauranttheme_hero_small_logo', false, 'url') !== '' ) { ?>
    <?php $images = rwmb_meta( 'restauranttheme_hero_small_logo', 'type=image_advanced&size=full' );
        foreach ( $images as $image ) {
            echo "<img src='{$image['url']}'>"; } ?>
   <?php } else { ?>
            <h1 class="mini-title"><?php echo rwmb_meta('restauranttheme_hero_title' ); ?></h1>
   <?php }  ?>

我也尝试过:

<?php if( '' != rwmb_meta('restauranttheme_hero_small_logo' ) ) { ?>
    <?php $images = rwmb_meta( 'restauranttheme_hero_small_logo', 'type=image_advanced&size=full' );
        foreach ( $images as $image ) {
            echo "<img src='{$image['url']}'>"; } ?>
    <?php } else { ?>
           <h1 class="mini-logo"><?php echo rwmb_meta('restauranttheme_hero_title' ); ?></h1>
    <?php } ?>

我猜错误是在我的if else语句中。 有人可以帮忙吗?

非常感谢

0 个答案:

没有答案
相关问题