if-statement难度与多个ifelse

时间:2017-09-16 01:01:05

标签: php if-statement

我在做一些简单的错误。任何人都可以快速帮忙吗?

    <?php 
    global $wp_query;
    $postid = $wp_query->post->ID;                  
    $Property_Type = get_post_meta($postid, 'Property_Type', true);
    if ($Property_Type == 'Residential') { ?>
     Single Family

      <?php 
       elseif ($Property_Type == 'Business Opportunity') { ?>
        Biz Opp  <?php }

           else { ?>   

          <?php echo c2c_get_custom('Property_Type'); ?>

   <?php } ?>

1 个答案:

答案 0 :(得分:1)

我不确定我做错了什么,但下面有效

    <?php 
    global $wp_query;
    $postid = $wp_query->post->ID;                  
    $Property_Type = get_post_meta($postid, 'Property_Type', true);
    if ($Property_Type == 'Residential') { ?>

    Single Family  

<?php } elseif ($Property_Type == 'Business Opportunity') { ?>

    Biz Opp
   
    <?php echo c2c_get_custom('Property_Type'); ?>

<?php } ?>
相关问题