Methods of payment Abuse

How to Restore a WordPress Website After a Hack

03.01.2025, 19:00

A hacked website is always a source of stress, especially if the issue is discovered too late. The site can end up on search engine blacklists and be flagged as “unsafe,” which leads to a significant drop in traffic, sometimes to almost zero. Restoring the site to normal operation is a lengthy process, and search rankings may suffer greatly. Let’s look at a proven and effective way to restore a website after a hack.

Step 1: Identify the WordPress Version

First, determine which version of WordPress was installed. You can check this in the admin panel. If the site is completely inaccessible, open the file public_html/wp-includes/version.php. Then, visit the official WordPress website and download the same version.

Step 2: Work on a Local Server

It’s better to perform the restoration on a local computer since it’s faster and safer. If you prefer working on the hosting server, keep in mind that the infection could spread to other sites hosted on the same server.

Step 3: Install a Clean Version of WordPress

Download a clean copy of WordPress and install it on a local server.

Step 4: Export and Edit the Database

  1. Log into PHPMyAdmin and export the site’s database.

  2. Open the exported file in a text editor. Use the find-and-replace function to replace all site URLs with the local address (e.g., replace site.ru with test/).

  3. Save the changes.

Step 5: Import the Database to the Local Server

  1. In PHPMyAdmin, create a new database, such as wp2 for convenience.

  2.  Import the modified database dump.

  3. Check and update the database prefix if necessary.

Step 6: Configure the Settings

Open the wp-config.php file and update the database connection parameters: database name, username, and password. Now, try opening the site. You will likely see a message indicating that the theme is missing. This is normal.

Step 7: Access the Admin Panel

  1. Log into the site’s admin panel. If you’ve lost the login credentials, reset the admin password — it’s easy to do.

  2. In the “Plugins” section, you’ll see a list of all previously installed plugins. Activate them through the admin interface.

Step 8: Restore the Theme and Media Files

  1. Transfer the theme folder and the uploads directory containing images.
  2. Check these files for malicious code. You can use a local server, a virtual machine with FastPanel, or the Linux Malware Detect utility for this purpose.

After completing all these steps, your site should be up and running again. To avoid similar problems in the future, remember to regularly update WordPress, plugins, and themes, and use reliable tools to protect your site.