Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.