In a theme I'm developing I would like to have a button with a mailto: href so that it when a user clicks on it, it generates the email address dependent on the post author.

I've managed to get it so that the email subject is generated from the post title by simply using the the_title();

I can't seem to work out how to dynamically generate the email address though. I need to replace the "[email protected]" part that is hard-coded below to automatically be the post author's email that is registered in their user profile in the back end.

I was looking at get_the_author_meta(); function, but this only seems to allow you to add a parameter for 'user_email' and then you have to manually add the user ID, which again is no use.

<a href="mailto:[email protected]?subject=<?php the_title(); ?>">Apply</a>

Any help would be amazing.

2 Answers 2


You can use get_the_author_meta function. You can learn more about it here: https://developer.wordpress.org/reference/functions/get_the_author_meta/

Usage in your case:

<a href="mailto:<?php echo get_the_author_meta('user_email');?>?subject=<?php the_title(); ?>">Apply</a>
  • 1
    what? This is the same answer I gave! Only I put it in an hour earlier!
    – rudtek
    Jan 9, 2018 at 17:00

Try using author_meta.

      $author_email = get_the_author_meta('user_email');
<a href="mailto:<?php echo $author_email;?>?subject=<?php the_title(); ?>">Apply</a>

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.