Reinstall WordPress Core via CLI
Reinstalling the WordPress core files via WP-CLI is a fast way to fix corrupted core files or remove suspicious code from your installation.
Always create a backup of your website before proceeding. Reinstalling core files cannot be undone.
Reinstall the core files
Log in to your server via SSH. If you're not sure how, follow this guide.
Navigate to the root directory of your WordPress installation:
bashcd public_htmlVerify you're in the correct directory by checking for the
wp-config.phpfile.Optional but recommended: Delete thewp-adminandwp-includesdirectories before reinstalling. This helps remove any unwanted or malicious code that may have been injected into the core.bashrm -rf wp-admin rm -rf wp-includesReinstall the WordPress core files:
bashwp core download --forceUpdate the database if needed:
bashwp core update-db
Your core files are now successfully reinstalled.
