WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

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>';
 /* ... */
share|improve this answer
Thank you @peteroak, works great!. Only I had to adjust some changes with ["]: echo "<a href=mailto:", $mail. ">", $mail."</a>";' – Inao V. Aug 6 '12 at 15:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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