Jump to content

Adding php to WP Child Theme


jess888

Recommended Posts

I know very little about php; would love some help on a small task:

 

I want to add a function to my WP websites so that all email addresses are encoded to prevent spammers from getting them.

I understand that I can add this to my theme functions:

 



<?php antispambot('protectmy@email.com') ?>


 

I can get into the functions.php page of my child theme via the Editor, which says:

 



<?php
/**
* @package Make Child
*
* Add your custom functions here.
*/


 

But when I add the spambot function to the end of this code, the site crashes, so I know my syntax must be wrong.

 

Thank you in advance....

Link to comment
Share on other sites

I've not used this function (in fact, didn't even know it existed until now), but according to the codex the antispambot() function will output the email address so you need to hook it into a widget or shortcode output function, not just drop it into the functions.php file. Also, the function will only obfuscate the address(es) passed to it, so it's not going to be a situation where you add the code and all email addresses throughout the site are handled.

Link to comment
Share on other sites

I've not used this function (in fact, didn't even know it existed until now), but according to the codex the antispambot() function will output the email address so you need to hook it into a widget or shortcode output function, not just drop it into the functions.php file. Also, the function will only obfuscate the address(es) passed to it, so it's not going to be a situation where you add the code and all email addresses throughout the site are handled.

Thank you so much.  I will use a plugin, I think.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.