Protect your email address on a WordPress site

WordPress comes with some useful built in functions for sanitising and protecting content which are often underused. For example, ever needed to protect an email address on a site footer or contact template so it cannot be picked up by spammers? Enter ‘antispambot’!

Antispambot’s default usage is as follows where the email you want to hide is wrapped in the antispambot function. This will show the email address when displayed in a browser but will show a series of HTML entities such as “com” when viewing the HTML.

<?php echo antispambot( 'youremail@yoursite.com' ); ?>

If you wanted to take this a step further and include in a mailto link then you could use the following code:

<a href="mailto:<?php echo antispambot( 'youremail@yoursite.com' );?>"><?php echo antispambot( 'youremail@yoursite.com' );?></a>

Whilst its not a fool proof solution it will allow some protection for your on-site email addresses. Its something we use on every site we produce and you can read more about ‘antispambot’ at the WordPress Codex Antispambot.

Matt Peacock

Matt is an award-winning WordPress developer with over 11 years of web development experience. A WordPress devotee with a real passion for contributing and improving what he does on a daily basis, he builds websites that are the 'difference that makes the difference'. Matt is a former county champion golfer, NLP Practitioner, qualified life coach and has a degree in Psychology.

Share
Published by
Matt Peacock

Recent Posts

Why collaborative partnerships are the way to grow your agency

How do you go about growing your agency? Do you rely on repeat business and…

4 years ago

Didn’t get that promotion? Good

Following on from yesterday's post “if you want to be tougher, be tougher”, this is…

4 years ago

Why WordPress coding standards are everything

We were recently asked by someone why we relatively expensive and charged more than someone else…

6 years ago

Our first e-book is here, here is how you can get it

We are pleased to announce that our first e-book is now available to download on…

6 years ago

Weekly round-up of WordPress news – Vol 21

A nice mix this week of Wordpress guides and e-commerce posts make up this weeks…

7 years ago

Weekly round-up of WordPress news – Vol 20

GDPR features today and this is going to be a hot topic in WordPress and…

7 years ago

This website uses cookies.