WordPress Spam Code: Remove Dynamically Inserted Code

WordPress Spam Code: Remove Dynamically Inserted Code

Not every plugin/theme developer has the customers’ best interest at heart. That being said, some developers may dynamically insert code into your WordPress installation which is bound to bring up some errors when one scan their site on Sucuri Malware Test.

Why is downloading nulled WordPress plugins and themes is a bad idea? Some of the code maybe due to users downloading and installing themes/plugins from unofficial websites (especially for paid plugins/themes that are nulled). Some of the uploaders of these “free” resources have sinister ways of making money.

An example being, one of our clients had his website inserted some cryptocurrency mining code which definitely made the culprit earn 100s of dollars without their knowledge!

WARNING – make sure you make a backup copy of your functions.php file before you make any modifications to it.

Method 1

Looking for how to remove malicious code from your WordPress site? Edit your functions.php…look for code containing wp_footer (as the code you are trying to remove is located there).

You should find the following lines (or similar):


and delete it.. it should remove the code for ever!


Method 2

Search in your theme folder the file “options.php” normally is in “/inc/options.php”. Inside this file search


and delete this line.

Method 3:

Are you using the Total Theme for WordPress? Some users have recently complained that they (theme developers) were inserting links into the theme as well. If you go into functions.php, look for a piece of code that looks something like this (for me it was the last function in the file):


If you delete the entire function, somehow it breaks the admin panel BUT if you modify it like so:


it seems to work.

If you are using any sort of caching plugin, you will probably need to clear your cache (and your browser’s cache as well) to see the change.


Did the above tutorial help? If not, tell us below how you solved the issue on your end or reach out to us and we will help you get rid of the code!

Leave a Reply

Your email address will not be published. Required fields are marked *