Need some help with trying to add on an if statement to the following code.
// determine email
$email = '<a href="mailto:' . get_post_meta($post->ID, 'resource_email', true) . '">'. get_post_meta($post->ID, 'resource_email', true) .'</a>';
$tpl = str_replace( '%%EMAIL%%', $email, $tpl );
What I would like to do, is this:
If there's an email display it like this...
<p><i class="icon"></i><a href="mailto:' . get_post_meta($post->ID, 'resource_email', true) . '">'. get_post_meta($post->ID, 'resource_email', true) .'</a><p>
If there's not email, display nothing.
Not sure how to do this, I've tried this, but failed :-)
// determine email
$email = '<a href="mailto:' . get_post_meta($post->ID, 'resource_email', true) . '">'. get_post_meta($post->ID, 'resource_email', true) .'</a>';
if ($email) {
'<i class="ss-mail"></i><h6>Email</h6><p>';
$tpl = str_replace( '%%EMAIL%%', $email, $tpl );
'</p>';
}
Thanks