[英]PHP mailto: variable with faicon inline
this code is suppose to see if the ACF variable is empty if not prints html code of globe fa icon with mailto: variable called mail yet its not working any ideas? 这段代码是假设如果ACF变量不为空,则不打印带有mailto的Globe fa图标的html代码:名为mail的变量,但它不起作用吗?
<?php
if((the_field('Email'))!=""){
$mail = the_field('Email');
echo '<a href="mailto:'.$mail.'"><i class="fa fa-envelope-o fa-2x"></i></a>';
}
?>
It is the basic thing there is the difference between get_field and the_field. 最基本的是get_field和the_field之间是有区别的。
the_field print the data and get_field required echo to print the value. the_field打印数据,而get_field需要回显以打印值。 Assuming the meta key name is Email.
假定元密钥名称是Email。 Use below code
使用以下代码
<?php
if(get_field('Email')!=""){
$mail = get_field('Email');
echo '<a href="mailto:'.$mail.'"><i class="fa fa-envelope-o fa-2x"></i></a>';
}
?>
I don't quite get the question but can you try: 我不太清楚这个问题,但您可以尝试:
<?php
if((the_field('Email'))!=""){
$mail = the_field('Email');
echo '<a href="mailto:'.$mail.'"><i class="fa fa-envelope-o fa-2x">'.$mail.'</i></a>';
}
?>
如我所见,the_field是一个函数,此函数返回一个邮件字符,因此有关the_fileld('email')的返回值为Null,我认为这意味着您的问题出在此函数中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.