Ready to get started?Download WordPress


[resolved] email address (3 posts)

  1. metrocitizen
    Posted 11 months ago #

    How can I enable an email address to be clickable?

  2. esmi
    Forum Moderator
    Posted 11 months ago #

  3. Ihor Vorotnov
    Posted 11 months ago #

    Better use it right way. WordPress has core function antispambot() which obfuscates your email address 'hiding' it from spam bots. Also, you don't need to hardcode the email address into template, this code automatically picks up blog admin email.

    <a class="email" href="mailto:<?php echo antispambot( get_bloginfo('admin_email', 'raw'), 1 ); ?>?subject=Hello" target="blank"><?php _e('Contact me', 'your_text_domain'); ?></a>

    To hardcode custom email address into temlate use this:

    <a class="email" href="mailto:<?php echo antispambot('info@yourdomain.com', 1 ); ?>?subject=Hello" target="blank"><?php _e('Contact me', 'your_text_domain'); ?></a>

    replace info@yourdomain.com with the email you want to insert.


You must log in to post.

About this Topic