Deploying old WordPress sites

I am primarily a Drupal developer but from time to time, I work on older WordPress websites. WordPress sites (5 years +), built and often maintained by different agencies or freelancers tend to be difficult to work with. There is a number of reasons for it, including various plugins, different coding and architectural standards, lack of version control, etc.

The first this to do is to back it up and deploy it on a local environment to scavenge content and investigate the functionality – something I’m often hesitant to do on older, live, semi-deprecated sites.

The backup consists of all WordPress files and my MySQL export. If possible I find and replace all the references in the live website domain. I normally use https://wordpress.org/plugins/wp-migrate-db/

There is no harm in running find and replace on the theme and custom plugins. Some paths might be hardcoded. Really ugly.

I tend to deploy the website on Docker, using the same server setting as on the live environment. WordPress plugins can be quite picky.

As a precaution, always block your dev environment from sending emails. The website might use an SMTP to send emails.

In this article, I will list some common tasks worth checking when having issues redeploying websites.

This list is not final. The order is not significant.

The database

Ensure that the wp-config.php details are correct. If there are issues connecting with the database, use a clean wp-config.php from WordPress.org.

Ensure the find-end-replace was done correctly and keep in mind typos, especially forward slashes. For a standard website, I normally do 2 replacements: //example.com to //domain.local and https://domain.local to http://domain.local. Note the 2 forward slashes.

Server settings

Check if you use the same server environment settings, such as the PHP version, PHP installed extensions, database version, and php.ini settings. I use Doker to map the settings on the local environment.

.htaccess

Be aware of the domain you are on. The live one or the dev one. It’s quite possible to remove certain things on the live website when investigating how it’s built. Best to log out from the live website – you can never be too careful!

Another important thing is to open the local website in an incognito window. The redirects saved in .htaccess are often aggressively cached by the browser. This can be especially annoying when setting up the local environment. Use an incognito window or clear your browser cache.

The best solution is to use the default .htaccess from WordPress.org.

Other

If all fails, start removing plugins one by one. This might help you to find the issue. If all plugins are removed but the website still throws errors, move into removing themes, one by one.

Remove the cached files, for example “/wp-content/cache”.