E-Mail A Post WordPress Function

I have been, or can be if you click on a link and make a purchase, compensated via a cash payment, gift, or something else of value for writing this post. Regardless, I only recommend products or services I use personally and believe will be good for my readers.

One of the first things most people do when they get on the Internet is send an e-mail. Then you start surfing, finding pages to share, and can easily click a button to post to Facebook, Tweet, Pin, or +1 some content.

Why isn’t there an elegant way to e-mail a page?

E-Mail A WordPress Post Plugin
E-Mail A WordPress Post
I’ve been thinking about this, and came up with a solution, which you can see in the sharing options on this page (between the post title and content, and again at the end of the article). Using the mailto: href and the mailto URL scheme, with a click of a button you can create a new email message with the subject pre-populated with the post title, and the message body containing the post description and URL.

I’m using a Thesis hook for my social sharing block (explained here) and replaced StumbleUpon with an email option:

<a href="mailto:?subject=<?= urlencode(get_the_title($post->ID)) ?>&body=<?= urlencode(get_permalink($post->ID) . "\n" . get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true)) ?>" target="_blank"><img src="/wp-content/themes/thesis_18/custom/images/icon-email.png" width="59" height="20" border="0" alt="Email" /></a>

To get rid of “smart” quotes in the post title (e-mail subject), I also added

remove_filter('the_title', 'wptexturize');

No third party tools. No forms to fill out. Just click a button, and a user can email your page.

It’s the original sharing tool.

  • WPBounce
    Posted May 25, 2012 6:04 pm 0Likes

    Once again. Genius things are simple.

Leave A Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.