Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sorry but I get lost on Wordpress's codex. I am trying to add a mail this page sharing link and want to include some info from the page. In pseudo code is this possible?

<a href="mailto:?subject=".CURRENT_BLOG_NAME." ".CURRENT_PAGE_TITLE."&amp;body="intro%20text%20".WP_PLUGIN_URL.$_SERVER['REQUEST_URI'].">Mail to a friend</a>

Where CURRENT_BLOG_NAME is ??? and CURRENT_PAGE_TITLE is ???

WP_PLUGIN_URL.$_SERVER['REQUEST_URI'] does get me the path to the current page.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted
<?php
$link = 'mailto:?subject='. get_bloginfo() .' '. the_title_attribute(array('echo'=>0));
$link .= '&amp;body=some text '. get_permalink();
?>
<a href="<?php echo $link ?>">mail to a friend</a>
share|improve this answer
    
I think this is the long way but it works also 'http%3A%2F%2F'.$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI'] –  JohnnyBizzle Aug 16 '11 at 10:49
add comment

There's the wp_mail($to, $subject, $message, $headers, $attachments); function for such things.

Furthermore there's a function called get_permalink();. And another one called get_the_title();.

You can combine them in a function:

function wpse25552_mail_permalink()
{
    global $post;
    $post_id = $post->ID;

    $title = get_the_title( $post_id );
    $subject = sprintf( __('I want to share %1$s with you', YOUR_TEXTDOMAIN ), $title );

    $permalink = get_permalink( $post_id );
    $message = sprintf( __('Yo! Look what I've found here: %1$s', YOUR_TEXTDOMAIN), $permalink );

    // ... stuff for $to, $subject, etc.

    wp_mail($to, $subject, $message, $headers, $attachments);
}

Note, that you have to replace YOUR_TEXTDOMAIN with your themes textdomain string. Else you can leave it out (don't forget to delete the comma too).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.