A good contact page is crucial for your WordPress website, especially for customer communication. However, posting a phone number can lead to spam calls and spoofing, caused by number-scraping bots. Here you can read how you can protect your telephone number without losing your accessibility.
Why hide your phone number?
Spam calls and spoofing are increasingly becoming a problem. Companies want to remain reachable by telephone, but also want to be protected against such unwanted calls.
How to hide a phone number behind a button
Method #1: Using code
Adding a script to the functions.php file hides the number behind a button, making it less easy for spambots to scrape it. Human visitors can see the number by clicking the button.
function showNumber() { var btn = document.getElementById(“numberToggle”); if (btn.innerText === “Toon nummer”) { var number = document.createElement(“SPAN”); var numberText = document.createTextNode(“+31 (0) 6 12 34 56 78”); number.id = “number”; number.appendChild(numberText); document.getElementById(“test”).appendChild(number); btn.innerText = “Hide number”; } else { document.getElementById(“number”).remove(); btn.innerText = “Show number”; } }
Method #2: Using a plugin
If you don't want to dig into the code, you can use the free Email Encoder plugin to protect phone numbers and email addresses.
And finally
Hiding a phone number behind a button significantly reduces the risk of spam calls and spoofing, although it is not a foolproof solution.
- Less chance of spam calls.
- Reduced chance of number spoofing.
- Maintaining accessibility for human visitors.
- No need for technical knowledge when using a plugin.
- Improved security of contact information.
Would you like to know more about securing your WordPress website? Then take a look at our WordPress maintenance plan.






