0

谁能帮我为这个语句编写代码

<?php if(get_post_meta($post->ID, "price", $single = true) != ""){ ?>
<?php echo get_post_meta($post->ID, "price",$single = true); ?>
<?php } ?>

如果在我的自定义字段中为空,我希望语句继续使用此代码

<?php $asin = get_post_meta($post->ID, 'asin', true);
echo azon_us_price($asin);
 ?>
4

1 回答 1

0

我想你想这样做:

<?php
if(!empty(get_post_meta($post->ID, "price", $single = true))){ 
  echo get_post_meta($post->ID, "price",$single = true); 
} else {
  $asin = get_post_meta($post->ID, 'asin', true);
  echo azon_us_price($asin);
}
?>
于 2013-02-09T14:29:24.517 回答