我在前端显示邮件和手机的值。
如何隐藏或设置为javascript:void(0)
这是我目前的代码:
section id="page-content" class="col-md-8">
<h3>About <?php the_title(); ?></h3>
<ul class="people-single unstyled inline-block">
<li><a href="mailto:<?php echo(types_render_field("person-email", array('raw' => true) )) ; ?>" target="_blank" class="hvr-hang"><span class="glyphicon glyphicon-envelope" aria-hidden="true"></span></a></li>
<li><a href="tel:<?php echo(types_render_field("person-phone", array('raw' => true) )) ; ?>" target="_blank" class="hvr-hang"><span class="glyphicon glyphicon-earphone" aria-hidden="true"></span></a></li>
</ul>
<?php the_content(); ?>
</section>
答案 0 :(得分:0)
这样的事情应该有效:
<?php
$personalEmail = types_render_field("person-email", array('raw' => true) ));
$personalPhone = types_render_field("person-phone", array('raw' => true) ));
?>
<ul class="people-single unstyled inline-block">
<?php
if($personalEmail != "")
{ ?>
<li><a href="mailto:" target="_blank" class="hvr-hang"><span class="glyphicon glyphicon-envelope" aria-hidden="true"></span></a></li>
<?php
}
if($personalPhone != "")
{ ?>
<li><a href="tel:" target="_blank" class="hvr-hang"><span class="glyphicon glyphicon-earphone" aria-hidden="true"></span></a></li>
} ?>
</ul>
如果电子邮件或电话号码不是空白,则会显示电话号码或电子邮件。