WP CLI Commands for Bluehost Cloud
The WP-CLI, or WordPress Command Line Interface, is a very powerful tool that lets developers and administrators manage their WordPress sites from the command line. WP-CLI enables you to update your plugins, configure multisite installations, manage posts and users, and do many other things without ever logging into the WordPress admin dashboard. This tool will streamline workflows, enhance productivity, and provide a more efficient way to handle routine WordPress development and maintenance tasks.
The following is a breakdown of the most used commands and their functions:
- To get a description of options for any command, you can type:
wp help <command> - For example, to get help with the db command, you would type:
wp help db
This will list various documentation regarding the syntax and options available for the wp db command.
CACHING | |
---|---|
Command | Task |
wp cache | Adds, removes, fetches, and flushes the WP Object Cache object. |
wp cache add | Adds a value to the object cache. |
wp cache delete | Removes a value from the object cache. |
wp cache flush | Flushes the object cache. |
wp cache type | Attempts to determine which object cache is being used. |
wp cap | Adds, removes, and lists capabilities of a user role. |
USER CAPABILITIES, ADMIN | |
Command | Task |
wp cap add | Adds capabilities to a given role. |
wp cap list | Lists capabilities for a given role. |
wp cap remove | Removes capabilities from a given role. |
wp super-admin add | Grants super admin privileges to one or more users. |
wp super-admin list | Lists users with super admin capabilities. |
wp super-admin remove | Removes super admin privileges from one or more users. |
WP CLI | |
Command | Task |
wp cli | Reviews current WP-CLI info, checks for updates, or views defined aliases. |
wp cli alias | Retrieves, sets and updates aliases for WordPress Installations. |
wp cli cache | Manages the internal WP-CLI cache,. |
wp cli check-update | Checks to see if there is a newer version of WP-CLI available. |
wp cli cmd-dump | Dumps the list of installed commands, as JSON. |
wp cli completions | Generates tab completion strings. |
wp cli has-command | Detects if a command exists |
wp cli info | Prints various details about the WP-CLI environment. |
wp cli param-dump | Dumps the list of global parameters, as JSON or in var_export format. |
wp cli update | Updates WP-CLI to the latest release. |
wp cli version | Prints WP-CLI version. |
WORDPRESS COMMENTS | |
Command | Task |
wp comment | Creates, updates, deletes, and moderates comments. |
wp comment approve | Approves a comment. |
wp comment count | Counts comments, on whole blog or on a given post. |
wp comment create | Creates a new comment. |
wp comment delete | Deletes a comment. |
wp comment exists | Verifies whether a comment exists. |
wp comment generate | Generates some number of new dummy comments. |
wp comment get | Gets the data of a single comment. |
wp comment list | Gets a list of comments. |
wp comment meta | Adds, updates, deletes, and lists comment custom fields. |
wp comment recount | Recalculates the comment_count value for one or more posts. |
wp comment spam | Marks a comment as spam. |
wp comment status | Gets the status of a comment. |
wp comment trash | Trashes a comment. |
wp comment unapprove | Unapproves a comment. |
wp comment unspam | Unmarks a comment as spam. |
wp comment untrash | Untrashes a comment. |
wp comment update | Updates one or more comments. |
WP CORE | |
Command | Task |
wp core | Downloads, installs, updates, and manages a WordPress installation. |
wp core check-update | Checks for WordPress updates via Version Check API. |
wp core download | Downloads core WordPress files. |
wp core install | Runs the standard WordPress installation process. |
wp core is-installed | Checks if WordPress is installed. |
wp core multisite-convert | Transforms an existing single-site installation into a multisite installation. |
wp core multisite-install | Installs WordPress multisite from scratch. |
wp core update | Updates WordPress to a newer version. |
wp core update-db | Runs the WordPress database update procedure. |
wp core verify-checksums | Verifies WordPress files against WordPress.org’s checksums. |
wp core version | Displays the WordPress version. |
WP CRON | |
Command | Task |
wp cron | Tests, runs, and deletes WP-Cron events; manages WP-Cron schedules. |
wp cron event | Schedules, runs, and deletes WP-Cron events. |
wp cron schedule | Gets WP-Cron schedules. |
wp cron test | Tests the WP Cron spawning system and reports back its status. |
DATABASE | |
Command | Task |
wp db | Performs basic database operations using credentials stored in wp-config.php. |
wp db check | Checks the current status of the database. |
wp db clean | Removes all tables with `$table_prefix` from the database. |
wp db cli | Opens a MySQL console using credentials from wp-config.php |
wp db columns | Displays information about a given table. |
wp db create | Creates a new database. |
wp db drop | Deletes the existing database. |
wp db export | Exports the database to a file or to STDOUT. |
wp db import | Imports a database from a file or from STDIN. |
wp db optimize | Optimizes the database. |
wp db prefix | Displays the database table prefix. |
wp db query | Executes a SQL query against the database. |
wp db repair | Repairs the database. |
wp db reset | Removes all tables from the database. |
wp db search | Finds a string in the database. |
wp db size | Displays the database name and size. |
wp db tables | Lists the database tables. |
EMBED | |
Command | Task |
wp embed | Inspects oEmbed providers, clears embed cache, and more. |
wp embed cache | Finds, triggers, and deletes oEmbed caches. |
wp embed fetch | Attempts to convert a URL into embed HTML. |
wp embed handler | Retrieves embed handlers. |
wp embed provider | Retrieves oEmbed providers. |
EVAL | |
Command | Task |
wp eval-file | Loads and executes a PHP file. |
wp eval | Executes arbitrary PHP code. |
EXPORT/ IMPORT | |
Command | Task |
wp export | Generates one or more WXR files containing authors, terms, posts, comments, and attachments. WXR files do not include site configuration (options) or the attachment files themselves. |
wp import | Imports content from a given WXR file. |
WORDPRESS LANGUAGE | |
Command | Task |
wp language | Installs, activates, and manages language packs. |
wp language core | Installs, activates, and manages core language packs. |
wp language plugin | Installs, activates, and manages plugin language packs. |
wp language theme | Installs, activates, and manages theme language packs. |
WORDPRESS MEDIA | |
Command | Task |
wp media | Imports files as attachments, regenerates thumbnails, or lists registered image sizes. |
wp media fix-orientation | Fix image orientation for one or more attachments. |
wp media import | Creates attachments from local files or URLs. |
wp media image-size | Lists image sizes registered with WordPress. |
wp media regenerate | Regenerates thumbnails for one or more attachments. |
WORDPRESS MENU/ SIDEBAR/ WIDGET | |
Command | Task |
wp menu create | Creates a new menu. |
wp menu delete | Deletes one or more menus. |
wp menu item | List, add, and delete items associated with a menu. |
wp menu list | Gets a list of menus. |
wp menu location | Assigns, removes, and lists a menu’s locations. |
wp sidebar list | Lists registered sidebars. |
wp widget add | Adds a widget to a sidebar. |
wp widget deactivate | Deactivates one or more widgets from an active sidebar. |
wp widget delete | Deletes one or more widgets from a sidebar. |
wp widget list | Lists widgets associated with a sidebar. |
wp widget move | Moves the position of a widget. |
wp widget reset | Resets sidebar. |
wp widget update | Updates options for an existing widget. |
NETWORK | |
Command | Task |
wp network meta | Gets, adds, updates, deletes, and lists network custom fields. |
WORDPRESS OPTIONS | |
Command | Task |
wp option add | Adds a new option value. |
wp option delete | Deletes an option. |
wp option get | Gets the value for an option. |
wp option get-autoload | Gets the ‘autoload’ value for an option. |
wp option list | Lists options and their values. |
wp option patch | Updates a nested value in an option. |
wp option pluck | Gets a nested value from an option. |
wp option set-autoload | Sets the ‘autoload’ value for an option. |
wp option update | Updates an option value. |
PLUGIN | |
Command | Task |
wp plugin activate | Activates one or more plugins. |
wp plugin auto-updates | Manages plugin auto-updates. |
wp plugin deactivate | Deactivates one or more plugins. |
wp plugin delete | Deletes plugin files without deactivating or uninstalling. |
wp plugin get | Gets details about an installed plugin. |
wp plugin install | Installs one or more plugins. |
wp plugin is-active | Checks if a given plugin is active. |
wp plugin is-installed | Checks if a given plugin is installed. |
wp plugin list | Gets a list of plugins. |
wp plugin path | Gets the path to a plugin or to the plugin directory. |
wp plugin search | Searches the WordPress.org plugin directory. |
wp plugin status | Reveals the status of one or all plugins. |
wp plugin toggle | Toggles a plugin’s activation state. |
wp plugin uninstall | Uninstalls one or more plugins. |
wp plugin update | Updates one or more plugins. |
wp plugin verify-checksums | Verifies plugin files against WordPress.org’s checksums. |
POSTS | |
Command | Task |
wp post create | Creates a new post. |
wp post delete | Deletes an existing post. |
wp post edit | Launches system editor to edit post content. |
wp post exists | Verifies whether a post exists. |
wp post generate | Generates some posts. |
wp post get | Gets details about a post. |
wp post list | Gets a list of posts. |
wp post meta | Adds, updates, deletes, and lists post custom fields. |
wp post term | Adds, updates, removes, and lists post terms. |
wp post update | Updates one or more existing posts. |
wp post url-to-id | Gets the post ID for a given URL. |
wp post-type get | Gets details about a registered post type. |
wp post-type list | Lists registered post types. |
REWRITE | |
Command | Task |
wp rewrite | Lists or flushes the site’s rewrite rules, updates the permalink structure. |
wp rewrite flush | Flushes rewrite rules. |
wp rewrite list | Gets a list of the current rewrite rules. |
wp rewrite structure | Updates the permalink structure. |
DATABASE/PHP | |
Command | Task |
wp shell | Opens an interactive PHP console for running and testing PHP code. |
WEBSITE | |
Command | Task |
wp site activate | Activates one or more sites. |
wp site archive | Archives one or more sites. |
wp site create | Creates a site in a multisite installation. |
wp site deactivate | Deactivates one or more sites. |
wp site delete | Deletes a site in a multisite installation. |
wp site empty | Empties a site of its content (posts, comments, terms, and meta). |
wp site list | Lists all sites in a multisite installation. |
wp site mature | Sets one or more sites as mature. |
wp site meta | Adds, updates, deletes, and lists site custom fields. |
wp site option | Adds, updates, deletes, and lists site options in a multisite installation. |
wp site private | Sets one or more sites as private. |
wp site public | Sets one or more sites as public. |
wp site spam | Marks one or more sites as spam. |
wp site switch-language | Activates a given language. |
wp site unarchive | Unarchives one or more sites. |
wp site unmature | Sets one or more sites as immature. |
wp site unspam | Removes one or more sites from spam. |
TAXONOMY, TERM | |
Command | Task |
wp taxonomy get | Gets details about a registered taxonomy. |
wp taxonomy list | Lists registered taxonomies. |
wp term create | Creates a new term. |
wp term delete | Deletes an existing term. |
wp term generate | Generates some terms. |
wp term get | Gets details about a term. |
wp term list | Lists terms in a taxonomy. |
wp term meta | Adds, updates, deletes, and lists term custom fields. |
wp term migrate | Migrate a term of a taxonomy to another taxonomy. |
wp term recount | Recalculates number of posts assigned to each term. |
wp term update | Updates an existing term. |
THEME | |
Command | Task |
wp theme activate | Activates a theme. |
wp theme auto-updates | Manages theme auto-updates. |
wp theme delete | Deletes one or more themes. |
wp theme disable | Disables a theme on a WordPress multisite install. |
wp theme enable | Enables a theme on a WordPress multisite install. |
wp theme get | Gets details about a theme. |
wp theme install | Installs one or more themes. |
wp theme is-active | Checks if a given theme is active. |
wp theme is-installed | Checks if a given theme is installed. |
wp theme list | Gets a list of themes. |
wp theme mod | Sets, gets, and removes theme mods. |
wp theme path | Gets the path to a theme or to the theme directory. |
wp theme search | Searches the WordPress.org theme directory. |
wp theme status | Reveals the status of one or all themes. |
wp theme update | Updates one or more themes. |
TRANSIENT | |
Command | Task |
wp transient delete | Deletes a transient value. |
wp transient get | Gets a transient value. |
wp transient list | Lists transients and their values. |
wp transient set | Sets a transient value. |
wp transient type | Determines the type of transients implementation. |
USER | |
Command | Task |
wp user add-cap | Adds a capability to a user. |
wp user add-role | Adds a role for a user. |
wp user application-password | Creates, updates, deletes, lists and retrieves application passwords. |
wp user check-password | Checks if a user’s password is valid or not. |
wp user create | Creates a new user. |
wp user delete | Deletes one or more users from the current site. |
wp user generate | Generates some users. |
wp user get | Gets details about a user. |
wp user import-csv | Imports users from a CSV file. |
wp user list | Lists users. |
wp user list-caps | Lists all capabilities for a user. |
wp user meta | Adds, updates, deletes, and lists user custom fields. |
wp user remove-cap | Removes a user’s capability. |
wp user remove-role | Removes a user’s role. |
wp user reset password | Resets the password for one or more users. |
wp user session | Destroys and lists a user’s sessions. |
wp user set-role | Sets the user role. |
wp user spam | Marks one or more users as spam. |
wp user term | Adds, updates, removes, and lists user terms. |
wp user unspam | Removes one or more users from spam. |
wp user update | Updates an existing user. |
JETPACK | |
Command | Task |
wp jetpack authorize_user | Allows authorizing a user via the command line and will activate |
wp jetpack block | Creates the essential files in Jetpack to build a Gutenberg block. |
wp jetpack call_api | Allows calling a WordPress.com API endpoint using the current blog's token. |
wp jetpack disconnect | Disconnect Jetpack Blogs or Users |
wp jetpack get_stats | API wrapper for getting stats from the WordPress.com API for the current site. |
wp jetpack module | Manage Jetpack Modules |
wp jetpack options | Manage Jetpack Optins |
wp jetpack partner_cancel | Cancel's the current Jetpack plan granted by this partner, if applicable |
wp jetpack partner_provision | Provision a site using a Jetpack Partner license |
wp jetpack protect | Manage Protect Settings |
wp jetpack publicize | Allows management of publicize connections. |
wp jetpack reset | Reset Jetpack options and settings to default |
wp jetpack scaffold | Creates the essential files in Jetpack to start building a Gutenberg block or plugin. |
wp jetpack sitemap | Manages your Jetpack sitemap |
wp jetpack status | Get Jetpack Details |
wp jetpack sync | Get the status of or start a new Jetpack sync. |
wp jetpack sync_queue | List the contents of a specific Jetpack sync queue. |
wp jetpack test-connection | Tests the active connection |
wp jetpack upload_ssh_creds | Allows uploading SSH Credentials to the current site for backups, restores, and security scanning. |
DISK USAGE | |
Command | Task |
wp disk-usage | Output disk usage information for the document root and tmp directories |
Summary
WP-CLI is a necessary utility in anyone's process to optimize the management of WordPress projects. The use of the command line means quick and very efficient execution of operations, where a person no longer must waste too much time on such things as manual maintenance. It will save a very considerable amount of time managing your sites, no matter whether you're a hard developer or simply a manager.