May.23

E-Mail A Post WordPress Function

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.

How To & Tips
Share this Story:
  • facebook
  • twitter
  • gplus

Comments(1)

  1. WPBounce
    1652 days ago

    Once again. Genius things are simple.

Leave a comment

Comment