best practices for updating wordpress theme

Developing locally is best practice in virtually all cases.

Getting a working replica of your site to develop on locally is pretty easy.

WordPress consists of some files (php, scripts etc) and also a database. We need to copy both to your local dev environment, and make a few changes so that it runs in its new ‘location’.

1st, I’d recommend using this plugin to export your database. It will change the URI’s, GUIDs etc that cause WP sites to break when you move them, and it will catch those stored within serialised arrays (which running regular SQL find/replace queries will not).

Migrate DB Plugin on WordPress.org

Now you have the SQL dump, you’ll need to import that into your database in your local dev environment.

Next, we need to copy all the files (including hidden i.e: .htaccess) from your live server to your local dev environment – this can be done any number of ways, but FTP is probably the most common.

Now we should have files AND the database, the last step is to change the wp-config.php file so that it contains the credentials for your local database (this will have a different name, user, password etc).

To up your game, check out this blog post by Mark Jaquith on using a wp-config-local.php file to store your local dev credentials, and using a small MU plugin he wrote to disable certain plugins in your local dev environment – this can be great for turning off things like W3-cache (if you use it)

Local Dev Tips: DB & Plugins by Mark Jaquith

Final words of advice – some plugins put stuff in your wp-config or .htaccess file: iThemes security and w3-total cache are two I see trip a lot of people up. Sometimes these plugins add domain specific things (cookie domain, redirect rules with the URL hardcoded etc) to these files, so if nothing is working, take a look at either of those two files.

I hope this is enough to get you started developing locally, it’s always better to work with data imported from the actual site than to just spin up a fresh WP install and hope it all works the same when you push to production.