Manage WordPress using WP-CLI
WP-CLI, also known as the wp command,
is a command-line utility for managing WordPress.
See the WP-CLI commands documentation for a full list of available commands.
To use the wp command,
SSH into your server as an app’s system user
and change your current directory to the app’s web root directory.
cd apps/APPNAME/publicFrom the app’s public/ directory,
use the wp commands shown on this page.
WP-CLI with WordPress Multisite
For apps using WordPress Multisite,
check the available flags for a wp command before running a command.
For some commands, you may need to provide the --network flag
to specify which Multisite network the command should operate on.
Manage WordPress users
Use the wp user command to manage WordPress user accounts.
See the
wp user documentation
for all available subcommands.
List users
See the
wp user list documentation
for all available flags.
wp user listCreate a user
See the
wp user create documentation
for all available flags.
wp user create USERNAME EMAIL --role=administratorA random password will be generated and displayed in the command’s output.
Change a user’s password
See
the wp user update documentation
for all available flags.
wp user update USERNAME --user_pass=PASSWORDChange a user’s role
See the
wp user update documentation
for all available flags.
wp user update USERNAME --role=ROLEThe available roles are:
administratoreditorauthorcontributorsubscriber
Delete a user
See the
wp user delete documentation
for all available flags.
Delete a user and all of their posts.
wp user delete USERNAMETo delete a user without deleting their posts,
use the --reassign flag to transfer the user’s posts to another user.
wp user delete USERNAME --reassign=OTHER_USERNAMEManage plugins
Use the wp plugin command to manage WordPress plugins.
See the
wp plugin documentation
for all available subcommands.
List installed plugins
See the
wp plugin list documentation
for all available flags.
wp plugin listInstall a plugin
See the
wp plugin install documentation
for all available flags.
wp plugin install PLUGIN_IDActivate a plugin
See the
wp plugin activate documentation
for all available flags.
wp plugin activate PLUGIN_IDUpdate plugins
See the
wp plugin update documentation
for all available flags.
Update a single plugin.
wp plugin update PLUGIN_IDUpdate all plugins.
wp plugin update --allDeactivate plugins
See the
wp plugin deactivate documentation
for all available flags.
Deactivate one plugin.
wp plugin deactivate PLUGIN_IDDeactivate all plugins.
wp plugin deactivate --allDelete a plugin
See the
wp plugin delete documentation
for all available flags.
wp plugin delete PLUGIN_IDManage themes
Use the wp themes command to manage WordPress themes.
See the
wp themes documentation
for all available subcommands.
List installed themes
See the
wp theme list documentation
for all available flags.
wp theme listInstall a theme
See the
wp theme install documentation
for all available flags.
wp theme install THEME_IDActivate a theme
See the
wp theme activate documentation
for all available flags.
wp theme activate THEME_IDUpdate themes
See the
wp theme update documentation
for all available flags.
Update a theme.
wp theme update THEME_IDUpdate all themes.
wp theme update --allDeactivate a theme
See the
wp theme deactivate documentation
for all available flags.
wp theme deactivate THEME_IDDelete a theme
See the
wp theme delete documentation
for all available flags.
wp theme delete THEME_IDSearch and replace
Use the wp search-replace command to replace contents of the WordPress database.
See the
wp search-replace documentation
for all available flags.
Use the --dry-run flag to see what the command would change
without making changes to the database.
wp search-replace "SEARCH_STRING" "REPLACEMENT_STRING" --dry-runWhen you’re ready to make changes to the database,
run the command without the --dry-run flag.
wp search-replace "SEARCH_STRING" "REPLACEMENT_STRING"Replace a domain name
To replace references to an old domain name in the WordPress database,
first use the --dry-run flag to see which tables and columns
have occurrences of the old domain name that will be replaced.
wp search-replace "old.example.com" "new.example.com" --dry-runThe output will look similar to the following.
+------------------------+-----------------+--------------+------+| Table | Column | Replacements | Type |+------------------------+-----------------+--------------+------+| wp_c7734cd387_comments | comment_content | 0 | SQL || wp_c7734cd387_links | link_url | 0 | SQL || wp_c7734cd387_links | link_image | 0 | SQL || wp_c7734cd387_options | option_value | 2 | SQL || wp_c7734cd387_posts | post_content | 1 | SQL || wp_c7734cd387_posts | post_title | 0 | SQL || wp_c7734cd387_posts | guid | 0 | SQL || wp_c7734cd387_users | display_name | 0 | SQL |+------------------------+-----------------+--------------+------+Success: 5 replacements to be made.When you’re ready to update the database,
run the command without the --dry-run flag.
wp search-replace "old.example.com" "new.example.com"