Php 从自定义字段回显外部链接-电子邮件(mailto:)
我现在有点像Php 从自定义字段回显外部链接-电子邮件(mailto:),php,wordpress,Php,Wordpress,我现在有点像 <?php $url = get_post_meta( get_the_ID(), 'email_address', true); if (!empty($url)) { ?> <img src="/wp-content/themes/ibusiness/img/mail.png"> <a href="<?php echo $url; ?>">Email Organisation</a> <p
<?php
$url = get_post_meta( get_the_ID(), 'email_address', true);
if (!empty($url))
{
?>
<img src="/wp-content/themes/ibusiness/img/mail.png">
<a href="<?php echo $url; ?>">Email Organisation</a>
<p>'<?php
}
?>
"
虽然这确实如我所期望的那样显示,但输出是一个带有附加到当前URL末尾的电子邮件地址的链接-无论我在哪里尝试添加邮件收件人:只需中断代码。替换
<a href="<?php echo $url; ?>">Email Organisation</a>
借
它可能会起作用。那么
呢?如果它出现在当前url的末尾,那么您的一个函数就有问题,您只需要电子邮件地址returned@Vector:记住相对URL是如何工作的。如果$url
是”foo@example.com
,则浏览器将解释URL并将其显示为http://www.current-site.com/current-page/foo@example.com“
。如果生成的url是正确的,这将起作用
<a href="mailto:<?php echo $url; ?>">Email Organisation</a>