Last active

Email Short Code

  • Download Gist
1 2 3 4 5 6 7 8 9
// Hide Email from Spam Bots using antispam bot
function HideMail($atts , $content = null ){
if ( ! is_email ($content) )
return '<a href="mailto:'.antispambot($content).'">'.antispambot($content).'</a>';
add_shortcode( 'email','HideMail');

All the above short code to your function file.

Now all you have to do is wrap the email address in [email][/email] for it work.

This short code updated Oct/2013 now uses the WordPress antispambot function reference.

I have forked your shortcode here: and made some important improvements to it:

  • using WordPress coding standards
  • removing the image in the link, that seemed very specific to the Robert's use case and not general use
  • adding validation that the passed string in $content is an email address, and if not, just return out of the function, avoiding potential issues if it wasn't an email address
  • added proper output escaping to the link, for security reasons

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.