Thursday, July 15, 2010

WordPress tip: Send article to a friend by email



Post Pic
WordPress tip: Send article to a friend by email

In order to create more traffic on your blog, it can be a good idea to let your readers send your posts to their friends by email. A few month ago, I already shown you a function to do that, here is an improved version for today.

To apply this recipe to your blog, simply paste the following function into your functions.php file, and that's all. Hard to do something simpler!
function direct_email($text="Send by email"){   
global $post;
$title = htmlspecialchars($post->post_title);
$subject = 'Sur '.htmlspecialchars(get_bloginfo('name')).' : '.$title;
$body = 'I recommend this page : '.$title.'. You can read it on : '.get_permalink($post->ID);
$link = '<a rel="nofollow"
href="mailto:?subject='.rawurlencode($subject).'&amp;body='.rawurlencode($body).'"
title="'.$text.' : '.$title.'">'.$text.'</a>';
return $link;
}

No comments:

Post a Comment