This document shows how to reinstall wordpress core files using wp-cli from a terminal. wp-cli needs to be installed. Enter
wp --info in the terminal to check. You can also use FTP as in this article https://community.reclaimhosting.com/t/replacing-wordpress-core-files/3294.
Get version inside Wordpress install directory
Open Terminal from cPanel > Advanced or SSH. Go to the install directory using linux commands. Try ll or ls -al to list the current folders and files. Then go to public_html (or the alias www) or to a subdomain folder using cd command for Change Directory. For example cd public_html will open the public_html folder where you can again use
ls -al again to see the contents. A Wordpress site will have many files starting with wp like wp-config.php.
cat command reads the version.php file to get the version number, while
grep looks for the text ‘wp_version’.
cat wp-includes/version.php | grep wp_version
Delete wp-admin and wp-includes directories (optional)
If malware is suspected for example you can delete the wp-admin and wp-includes directories.
rm stands for remove and we are using
-r for recursive to delete all the subdirectories and files and
-f for force without prompting.
rm -rf wp-admin wp-includes
Reinstall wp core
This is the wp-cli command to download the core files, while skipping the content folder (wp-content). The current version will be installed so this is the easiest method. This also means you can skip the step of finding the current version as described earlier.
wp core download --force --skip-content
reinstall using version
This is the wp-cli command to download the core files, while skipping the content folder (wp-content) and using in this case version 5.6.
wp core download --force --skip-content --version=5.6
Reinstall using version and locale
You can also specify the locale if needed to any language available for Wordpress.
wp core download --force --skip-content --locale=en_US --version=5.6