WP-CLI » Reinstall WordPress Core using WP-CLI

Reinstall WordPress Core using WP-CLI

We recently made a list of the most useful WP-CLI commands with examples and how to fix the most common WPCLI errors but there are a lot of maintenance tasks that can be done with WP-CLI that We haven’t included in this list.

One of those tasks is reinstalling WordPress Core using WP-CLI.

First, navigate to the directory where WordPress is installed and check the active version with

wp core version
image 15 - Reinstall WordPress Core using WP-CLI

One of the most common reasons We reinstall WordPress core is because the website was hacked and We want to get rid of any malicious files inside wp-admin and wp-includes directories.

rm -rf wp-admin wp-includes
  • rm stands for remove and we are using
  • -r for recursive to delete all the subdirectories and files
  • -f for force without prompting.
See also  Download WP-CLI & set custom PHP Version

To download the core files, while skipping the content folder (wp-content).

wp core download --force --skip-content --version=5.4.4
image 17 - Reinstall WordPress Core using WP-CLI

You can also specify the locale if needed with –locale:

wp core download --force --skip-content --locale=en_US --version=5.4.4

That’s it.

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended