What is WP-CLI?
WP-CLI is a tool that lets you manage WordPress by typing commands instead of clicking in the dashboard. CLI means command line interface. That is a screen where you type instructions as text. It is fast, and it works even when the dashboard is broken.
You need SSH access to use it. SSH is a safe way to connect to your server and type commands. Ask Hostvento support if WP-CLI is installed on your plan. To check, type wp --info.
Warning: updates can break a site if a plugin or theme does not match the new version. Always take a backup of your files and database first.
Steps
- Connect to your server with SSH.
- Go to your WordPress folder. It is often
public_html:
This moves you into that folder.cd ~/public_html - Back up the database:
This saves your database into a file calledwp db export backup.sqlbackup.sql. - Check your current version:
This prints the WordPress version number.wp core version - See if a core update exists:
This lists newer versions, if any.wp core check-update - Update WordPress core:
This downloads and installs the newest version.wp core update - Update the database after a core update:
This makes sure the database matches the new version.wp core update-db
Plugin commands
wp plugin list
This shows all plugins and tells you which have updates.
wp plugin update akismet
This updates one plugin. Replace akismet with the plugin's name.
wp plugin update --all
This updates all plugins at once.
Theme commands
wp theme list
This shows all themes and their update status.
wp theme update --all
This updates every theme.
Other handy commands
wp core verify-checksums
This checks that your core files have not been changed or damaged.
wp cache flush
This clears the object cache. A cache is a saved copy that makes your site faster.
After updating
- Open your site and click through the main pages.
- Log in to the dashboard and check for notices.
- If something broke, restore your backup, or turn off the last plugin you updated with
wp plugin deactivate plugin-name.
--allow-root only if you understand why. Usually, use your normal account.Quick recap
- WP-CLI manages WordPress from the command line over SSH.
- Back up first with
wp db export. - Use
wp core update,wp plugin update --allandwp theme update --all. - Test your site after every update.