Reinstalling WordPress Core Files Using WP-CLI

If WordPress is misbehaving in a way that points at damaged core files - a blank screen after an interrupted update, files a scanner has quarantined, or a site you are cleaning up after a compromise - you can replace the core files without touching your content or your settings. This guide does it with WP-CLI over SSH.

Back up your site before you start. This overwrites files and cannot be undone. A backup takes a minute; recovering without one does not.

Before you start

  • SSH needs to be switched on. It is available on every plan except Amethyst, but it is off by default - turn it on from My Services in your client area. Our SSH port is 722, not the usual 22.
  • If you can't use SSH, skip to If you don't have SSH access at the end.

1. Connect, and go to your site's folder

cd ~/public_html

The ~ matters - it means "my home folder". If your site is an add-on domain or sits in a subfolder, change to that folder instead. Check you are in the right place:

ls -a

You should see wp-config.php, wp-content and wp-admin. If you don't, you are in the wrong folder.

2. Find out what is actually damaged

wp core verify-checksums

This compares every core file against the checksums WordPress.org publishes and lists anything that differs. It changes nothing, so it is always safe to run.

If it reports no problems, your core files are intact and reinstalling them will not help - the cause is more likely a plugin or theme, and you would be overwriting your site for nothing.

3. Note the version you are on

wp core version

Write the number down. You need it in the next step, and it is the difference between reinstalling and accidentally upgrading.

4. Reinstall the core files

wp core download --version=YOUR-VERSION --skip-content --force

Replace YOUR-VERSION with the number from step 3. Each part earns its place:

  • --version= pins it to the release you already have. Leave this out and you get the newest WordPress instead - an upgrade rather than a repair, with whatever plugin and theme breakage that brings.
  • --skip-content leaves wp-content alone. Without it, the download includes the default themes and plugins and writes them over what is on your site.
  • --force allows it to overwrite the files that are already there, which is the whole point.

Your wp-config.php is never touched - it isn't part of a WordPress download.

5. Check the site

Load the site and the wp-admin dashboard. If you want to confirm the repair worked, run wp core verify-checksums again - it should now come back clean.

6. Update the database, if the version changed

wp core update-db

Only needed if you deliberately moved to a different version. Reinstalling the same version does not require it.

Clearing the cache

wp litespeed-purge all

Optional, and only works if the LiteSpeed Cache plugin is installed and active - otherwise the command simply errors, which is nothing to worry about.

If your site isn't in public_html

Rather than changing folder first, you can point any of these commands at the site with --path:

wp core verify-checksums --path=~/public_html/example

If you don't have SSH access

Amethyst doesn't include SSH, and not everyone wants to use a shell. The same job can be done by hand: download your exact WordPress version from wordpress.org/download/releases, unzip it, and upload everything except the wp-content folder and wp-config.php over your existing install using cPanel's File Manager, choosing to overwrite.

If you would rather not, open a ticket and we will take a look.


How did we do?

Powered by HelpDocs (opens in a new tab)
© Krystal Hosting Ltd 2002–