As the owner of a website, it’s important to place a contact information for readers or potential advertisers to get in touch with you. For a formal and better communication, it’s better for them to contact you via email since it’s much easier to manage and keep track of the communication.
There are two ways to encourage others to contact you via email, either by providing a contact form or by displaying your email address on the contact form page. In this article, we’ll show you how to prevent your email from being spammed by email harvester using a less-known WordPress antispambot fuction.
WordPress antispambot Function
For example, to display your email on any post, you may wrap your email in the antispambot function:
<?php antispambot( '[email protected]' ) ?>
What the function does is convert the email address to HTML entities. To make it even easier to use the function in any post, we may use a shortcode. First, we need to register a shortcode that can be used in our site. Simply put the following code in
functions.phpfile or even better, in your site’s functionality plugin.
Then, whenever you want to display an email address in your post, simply wrap the email in the
[email] shortcode. Example:
Safer Email Link Plugin
For non-tech savvy users, there’s a plugin called Safer Email Link plugin. This plugin will add a button in the post editor to help you quickly add the shortcode to your post.
Once the plugin is activated, you’ll see a new button in the TinyMCE editor. Clicking on it will insert the
[sf_email][/sf_email] shortcode to the post editor. Then, simply insert your email between the opening and closing shortcode like
We hope this tutorial helped you to avoid your email address being spammed in WordPress. Feel free to subscribe to our RSS feed to get latest WordPress tutorials straight to your mailbox or RSS reader.
Hayat pektus says
Your post is very understanding which is very good