Are you looking for a way to display share via email link? While there’s probably a plugin for this, we have created a quick code snippet that you can use to display share via email link in WordPress.
A simple link that opens users default email client to send an email to a friend or colleague. The second link is an extension to display an excerpt in the email body.
Instructions:
All you have to do is add this code to your theme’s single.php file or in a site-specific plugin:
<?php echo "<a href="mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20<?php bloginfo('name'); ?>&body=<?php the_title(); ?> - <?php the_permalink(); ?>" title="Email to a friend/colleague" target="_blank">Share via Email</a>"; ?>
<?php echo "<a href="mailto:type%20email%20address%20here?subject=I%20wanted%20to%20share%20this%20post%20with%20you%20from%20<?php bloginfo('name'); ?>&body=<?php the_title('','',true); ?>%20%20%3A%20%20<?php echo get_the_excerpt(); ?>%20%20%2D%20%20%28%20<?php the_permalink(); ?>%20%29" title="Email to a friend/colleague" target="_blank">Share via Email</a>"; ?>
Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.
If you liked this code snippet, please consider checking out our other articles on the site like: 9 best WordPress events plugins and how to create a contact form in WordPress.
Comments Leave a Reply