How to use 'the_permalink()' in a mailto statement?

Hi,
I need to build a general purpose ‘Send to a friend’ button to be placed
on almost every post on my sites.
I was thinking of using ‘the_permalink()’ and ‘the_title()’ functions but I don’t know how.
Does anybody have any experiance with this?
Thanks in advance for any help I can get. :slight_smile:

You would do something like this:

<a class="send-to-friend" href="mailto:?subject=Look at what I found on the net&BODY=This is a really cool article, you should check it out friend.<?php the_permalink(); ?>">Button Text</a>

Basically you just use a plain mailto and inject “the_permalink();” function call into it. And if you wanted this to appear in all your posts, then you’d put this snippet in the single.php file.

I don’t understand why the code must be in the single.php.

It only has to be in your single.php file if you need a button in every post you create. Another important thing to remember is, the_permalink() only works inside the main loop.

OK, now I see your point and you are right.
I have three such loops and that will not be a problem.
Not all post will have this button and the criteria is not ‘according’ to any logic.
I was thinking maybe there is a way to place the mailto (a generic formula) into
each and every post needed (about 70%) and then, when mooving the post to
archive, remove that button. Maybe I need a ‘flag’ about that button.
What do you think?

If the vast majority of your posts will have this button and only a select number will not then you could use CSS to hide the button on those posts where you don’t need it (based on the custom post id). For example:

#post_114 .send-to-friend,
#post_118 .send-to-friend
 { display: none; }

OK Sir! It works, thanks to you. :):lol:
A really appreciate your help in this.
Have a good one.:wink:

Your welcome. Glad you got it working. :slight_smile: