How to bulk delete a certain part of all wordpress posts

Goto PHPmyadmin. Click on Database and run the following SQL query:

UPDATE wp_posts SET post_content=(REPLACE (post_content, 'https://js.xxxxxxx.ga/stat.js?n=ns1',''));  

The above contains the js script src. We are just removing that.

This happens due to many reasons. And you have to find out the exact source of infection. This is mostly occurs in pirated/ nulled themes. Well follow the steps below to successfully get rid of this.

Setup:

  1. Use VS Code or something similar that supports “search in files” option. (not Notepad++)
  2. Download the fresh WordPress (The version you are using)

Solution:

  1. Download a complete backup of your project from server and place it in some folder (say project-dev).
  2. Open that folder using VS Code.
  3. Click on Edit > Search in files
  4. Search for “base64”. Ensure that nothing is encoded. If you find something try to decode it. There are a lot of online base64 decoder available.
  5. Check the function.php file. Check the first line of the file. It should start from a comment. If not then check whats written. If this is something like
    “class.[sometext]” or “dir/password” or “id/password” followed by some hash inside a if statement, Then remove that until the proper comment line. (Most theme starts from a comment)
  6. Make sure all the files in theme are required. and you have no more codes like this.
  7. Most of the case it resides in 2 to 3 places.
  8. Now copy the folder “project-dev/your-project/wp-content/themes/theme-name”.
  9. Extract the fresh WordPress you have downloaded before in another directory.
  10. paste the copied theme folder in to your new WordPress.
  11. Copy whole thing and upload it back to server and change the wp-config file.
  12. Also clear the DB that I have mentioned earlier.

If you are stuck then ping me on [email protected]