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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.