hey guys,
<?php urlencode(the_title()); ?>doesn’t take effect.

this is my entrie line of code:

<li><a href="https://wordpress.stackexchange.com/questions/14114/mailto:?subject=<?php urlencode(the_title()); ?>&amp;body=<?php the_permalink(); ?>">e-mail</a></li>

I don’t want to have spaces in the_title(). Why does urlencode not work for me?

1 Answer
1

The the_title() echo the title. You must use get_the_title() instead. get_the_title() returns the title as string. Use

<? echo urlencode(get_the_title()) ?>

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *