WP-CLI is a powerful command-line tool that allows you to manage your WordPress site without needing to log in to the admin dashboard. Whether you're updating plugins, creating users, or clearing the cache, WP-CLI can save you time and streamline your workflow. In this guide, we’ll go over some of the most commonly used WP-CLI commands to help you get started.
Run the command below in the web root directory of your website to list all available WP-CLI commands.
wp help
Run the command below in the web root directory of your website to list all installed plugins.
wp plugin list
Run the command below in the web root directory of your website to search for plugins in the WordPress plugin repository.
wp plugin search smtp
Run the command below in the web root directory of your website to install a plugin from the WordPress plugin repository.
wp plugin install wp-mail-smtp
Run the command below in the web root directory of your website to activate a specific plugin.
wp plugin activate wp-mail-smtp
Run the command below in the web root directory of your website to update one or more plugins to their latest versions.
wp plugin update wp-mail-smtp
Run the command below in the web root directory of your website to update WordPress core to the latest version.
wp core update
Run the command below in the web root directory of your website to check the currently installed WordPress version.
wp core version
Run the command below in the web root directory of your website to export your WordPress database to a
.sql
file.wp db export filename.sql
Run the command below in the web root directory of your website to import a
.sql
file into your WordPress database.wp db import latest.sql
Run the command below in the web root directory of your website to list all WordPress users.
wp user list
Run the command below in the web root directory of your website to delete the user bigscoots and reassign their content to the admin user.
wp user delete bigscoots --reassign=admin --yes
Run the command below in the web root directory of your website to create a new WordPress user bigscoots with administrator role and specified password.
wp user create bigscoots noreply@bigscoots.com --role=administrator --user_pass=Tj86o5pq1Omh
Run the command below in the web root directory of your website to update the password for the WordPress user bigscoots:
wp user update bigscoots --user_pass="Tj86o5pq1Omh"