如果还有其他方式,我该如何制作此代码?如果'Rental'为true,则执行此操作。...否则...执行false位。我迷失在PHP标记中。
<?php
if( get_post_meta($post->ID, 'Rental', true) ) {
?>
<li style="padding:3px 10px; line-height: 18px; height:34px"><strong><?php _e( 'Rental Potential / Actual', 'spanglishwebs' ) ?>:</strong> <?php
$priceWithoutFormat = get_custom_field('Rental');
$priceWithFormat = number_format($priceWithoutFormat, 0, ',', '.');
echo $priceWithFormat;
?>€/Annual </li>
<?php
}
if( get_post_meta($post->ID, 'Rental', false) ) {
?>
<li>Rental Potential / Actual: N/A</li>
<?php
}
?>
<?php if (get_post_meta($post->ID, 'Rental', true)) { ?>
<li style="padding:3px 10px; line-height: 18px; height:34px">
<strong><?php _e('Rental Potential / Actual', 'spanglishwebs') ?>:</strong>
<?php
$priceWithoutFormat = get_custom_field('Rental');
$priceWithFormat = number_format($priceWithoutFormat, 0, ',', '.');
echo $priceWithFormat; ?>€/Annual
</li>
<?php } else { ?>
<li>Rental Potential / Actual: N/A</li>
<?php } ?>
尝试一下是否有效,您的代码确实很乱...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句