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.
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.
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.
Download a clean copy of WordPress and install it on a local server.
Log into PHPMyAdmin and export the site’s database.
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/).
Save the changes.
In PHPMyAdmin, create a new database, such as wp2 for convenience.
Import the modified database dump.
Check and update the database prefix if necessary.
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.
Log into the site’s admin panel. If you’ve lost the login credentials, reset the admin password — it’s easy to do.
In the “Plugins” section, you’ll see a list of all previously installed plugins. Activate them through the admin interface.
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.