the graphic design blog that speaks the truth

I thought I’d share with you a handy little code snippet that enables you to add an “email this page” link to your WordPress posts and pages, without the need for a plugin. It is just one line of code, placed within the loop.

<a href="mailto:?subject=<?php the_title(); ?>&amp;
body=<?php the_title(); ?> - <?php the_permalink(); ?>">E-Mail This Page</a>

As you can see, in the form of a href, we have created a simple mailto, that takes information from the post as it’s parameters. The above example is taking the title as the e-mail subject and body, and adding the post permalink into the body as well.

You might also want to include other information about the post like the date or the post thumbnail(untested) for example.

There you have it, a simple, reusable “Mail This” code snippet.

ABOUT THE AUTHOR

SHARE THIS ARTICLE

Voice Your Opinion

Thanks for your comment, it will appear here once it has been moderated.