How to make an ‘email this post’ link in WordPress

This tips applies to coding a WordPress theme design. You won’t be able to copy and paste the code straight into your posts. You will need full access to editing themes on your server (yes, I can host WordPress sites if you contact me).

This is quite tricky to get to work and still have your HTML validate. It’s well worth making sure your WordPress site validates. Very few do. I use rawencode here because I found that the ridiculous Windows email client on this machine (which I never use except for testing this) doesn’t understand spaces encoded as “+”, it needs “%20″. Ho hum.

<a href=”mailto:?subject=<?php echo rawurlencode(get_the_title(get_the_ID())); ?>&amp;body=<?php echo rawurlencode(get_permalink(get_the_ID())); ?>”>Email this post</a>
Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

Leave a Comment