0

Hello All I was wondering if someone could help me out. I have multiple users for my blog and they are allowed to create posts. I would like to create a mailto: link on the single.php post for that specific post type. I would like the mailto: email to be the author's email of that specific posts so that a viewer could email the author of the post.

I am aware that wordpress has the function:

<?php $user_email = get_the_author_meta('user_email'); ?>

this function stores the data, i would really appreciate it if someone could help me display a mailto: link with this function.

har
  • 43
  • 10

1 Answers1

0

You can simply echo the value where you need it. For example:

<a href="mailto:<?php echo get_the_author_meta('user_email'); ?>">Click here to email author</a>

Or, more readable:

<?php 
    $user_email = get_the_author_meta('user_email'); 
    echo '<a href="mailto:' . $user_email . '">Click here to email author</a>';
?>
rnevius
  • 26,578
  • 10
  • 58
  • 86
  • Thank you for the rapid response Mevius. i was wondering if i could store that data in a variable then execute it without displaying the actual email maybe something like "click here to email author" – har Nov 07 '14 at 16:52
  • ` click here to email author'; ?>` THANK you very much mevius – har Nov 07 '14 at 16:55
  • is there a way to get the title of the post as the subject of the email.? or any metakey for example i have a metakey "name" could this potentially be used as a subject for teh email? – har Nov 07 '14 at 17:06
  • Definitely! See [this answer](http://stackoverflow.com/questions/4782068/can-i-set-subject-content-of-email-with-using-mailto) for more info. You can `echo` the post title with ``. – rnevius Nov 07 '14 at 17:29
  • ` click here to email agency'; ?> ` i tried something like this but it isnt working any thoughts? – har Nov 07 '14 at 18:53
  • always confused with the ' thank you so very much again. – har Nov 07 '14 at 21:02
  • The single quotes `'` end a string. The dots `.` "concatenate" a variable to the string. Another dot `.` after the variable and another single quote `'` starts the string up again. In other words, the strings are surrounded in single quotes and variables are attached to them with the dots. – rnevius Nov 07 '14 at 21:12