How To Manually Update WordPress Themes Elegantly

Sometimes your WordPress theme just doesn’t update properly using the standard update method for whatever reason. In these situations, you need to perform the updates manually to take advantage of the latest and greatest enhancements to your active WordPress theme. This is a guide on how to perform these updates manually in an elegant fashion.

If performed properly, this update process should only leave your site down with a clean maintenance landing page for at most five minutes.

Start with a maintenance landing page template like the following:


Simple Maintenance Page Template
Simple Maintenance Page Template

Steps to manually update your WordPress parent theme:

  1. Create a maintenance landing page. If you don’t want to make one from scratch I recommend using this Simple Maintenance Page template as a starting point. Customize it with your logo, favicon, styles and email address and save it as index.php, then create a maintenance folder in your web server’s public root directory and upload index.php into the new folder. You can view my maintenance page here. Make sure to add the following PHP code to it in order to set a 503 Service Temporarily Unavailable status code, you can easily verify the status code with httpstatus:
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 300');//300 seconds
  1. Create and activate a child theme if you haven’t already. Ensure all of your website settings, styles, and any other parent theme overrides are located within your child theme and none are stored in the parent theme.
  2. Download the latest version of your active WordPress parent theme.
  3. Create a new folder in the directory of your parent theme (e.g. /wp-content/themes/your-parent-theme/new) and upload all the files via SFTP from the latest version of your parent theme in this new folder. Alternatively, if you can access a file manager on your web server, upload the latest theme’s zip file and extract it on your server in this new folder to save a bunch of time and/or potential upload errors.
  4. Download a backup of all of your old parent theme’s files so you can restore them if anything goes wrong.
  5. Login to your WordPress dashboard and keep the tab open for later testing.
  6. Add the following code to your child theme’s function.php file to enable maintenance mode:
// maintenance mode toggle
function maintenance_mode() {
      if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {wp_redirect('/maintenance/');}
}

// comment line below to disable maintenance mode
add_action('get_header', 'maintenance_mode');
  1. Delete all of the old parent theme files, keeping only the new folder.
  2. Move all of the latest parent theme files up one directory from the new folder, then delete the new folder once it’s empty.
  3. Test your WordPress website to ensure everything is working properly as it was before the parent theme update using the tab already logged into the WordPress dashboard.
  4. Comment out the following line in your child theme’s functons.php file to disable maintenance mode:
//add_action('get_header', 'maintenance_mode');

For all future website maintenance, you can simply toggle commenting that line of code to enable/disable maintenance mode as needed.

LEAVE A REPLY

Please enter your comment!
Please enter your name here