0

I'm very confused with an "Email" custom field, how I can make it automatically clickable as "mailto:" link, inside a loop like this:

while ( $loop->have_posts() ) : $loop->the_post();
    $mail = get_post_meta($post->ID, 'mail', true);                                                                     
    if  ($mail) {
        echo the_title()."</br>",
        echo $mail;
    } /*... rest of the loop

Thanks in advance.

1 Answer 1

1

well you did all the hard stuff, so you can try this:

 while ( $loop->have_posts() ) : $loop->the_post();
    $mail = get_post_meta($post->ID, 'mail', true);   
    if  ($mail) {
        echo '<a href="mailto:'.$mail.'">email me at '.$mail.'</a>';
    } 
 /* ... */
1
  • Thank you @peteroak, works great!. Only I had to adjust some changes with ["]: echo "<a href=mailto:", $mail. ">", $mail."</a>";'
    – Inao V.
    Commented Aug 6, 2012 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.