We often find stories and interesting articles online which are worth sharing with friends. Mostly people never miss sharing product reviews, special discounts and offers on website. Tell a friend button is used to share article with your friends by personal email. Tell a friend button is also known has Email This button, which is similar to share button like tweetmeme button, facebook like or linkedin.
There are many plugins made to add Email button on WordPress, but depending upon third party plugins for simple code is just waste of resources and increasing server load by php calls. In this article, we will learn how to add tell a friend button without plugin in WordPress blog.
Tell a Friend Button Code
The analogy behind is that on click of the button, it will open a default email software and will add subject, link of the article and will prompt to enter friend’s email address. Below is the Email button code for WordPress, and you add the code in single.php file.
Make sure you take full backup of single.php file using FTP before modifying it.
<a class="email-share" href="mailto:?subject=Check this out&BODY=I found this article interesting and thought of sharing it with you. Check it out: <?php the_permalink(); ?>" target="_blank"></a>
Once done editing the php file, now apply some CSS on it. Copy-Paste the below code snippet in style.css file.
.email-share{ background:url('images/email.png') no-repeat; width:97px; height:23px; display:block; margin:10px 20px 10px 0; }
Download the the following image, by right clicking and Save Image as.. “email.png”
Place the downloaded image in the Theme Directory as {theme folder}/images/email.png
We are done!
After adding all code snippets, refresh the website and open any blog post, and you can see the email button demo below:
Email button Demo:
On click of above button, it will send the link of this blog that is www.thecreatology.com to the email address you enter.
If you have any query or require further assistance, you can post comment as your feedback.
Thanks for this e-mail…One small question: where ‘exactly’ should I place the code snippet in the single.php file?
Hi @Ewien you’re going to add it in your single.php file of your current theme, I’ve provided same tutorial and it quite contain everything you need, you can visit the tutorial at How to add “Email This Article to a Friend” in WordPress
this comment is old but it may help other users who find this site 😉
Still don’t understand exactly WHERE to place the code in single.php – on top, on bottom, between divs…?
Dear friends,
what happens if a client (ie person browsing the site) does NOT have a mail utility (outlook or such)??
thank you,
daniel
A system would automatically prompt for an Email Option, likely we have it in almost every system. But special cases may/can assign Gmail, Yahoo or AOL as their default Email Options too. Cheers! 😉
Cool idea – surprisingly there aren’t many plugins that do this.
Question: How to implement this where the theme is Parent/Child setup – in this case it’s Genesis.
TIA
The email button in the “Your turn now” part is not functioning.
We appreciate your concern.
There are few JavaScript conflicts with JetPack plugin and we are currently fixing it. We do regret the inconvenience caused.
.email-share{
background-color: #f60;
cursor: pointer;
color: #FFF;
padding: 10px;
width: 100%;
display: block;
text-align: center;
}