Returns sizes of all database tables in a human friendly format.

#wordpress#cli#db
wp db size --human-readable --tables
copy

Run health check on the database set in the wp-config.php file. It reports status of each database table separately in the output.

#wordpress#cli#db
wp db check
copy

Checks if WP-CLI is due for an update.

#wordpress#cli
wp cli check-update
copy

Return WP CLI version.

#wordpress#cli
wp cli version
copy

Creates config.php file. Requires mysql cli to be installed.

#wordpress#cli
wp config create --dbname=yourdbname --dbuser=root --prompt=dbpassword
copy

This command searches for all posts in the database and returns the count number.

#wordpress#cli
wp post list --format=count 
copy

Download latest version of WordPress core files to current directory.

#wordpress#cli
wp core download
copy

Opens wp-config.php file in the default text editor.

#wordpress#cli
wp config edit
copy

Exports WXR file containing XML formatted data about your site including posts, comments and information about images and other attachments. Site option settings are excluded.

#wordpress#cli
wp export
copy

By combining the following flags you can export a single page from WordPress. First set the post type you want to export (page) then set the ID of the post, and finally limit the command to only fetch a single post. Skipping comments is optional.

#wordpress#cli
wp export --skip_comments --post_type=page --post__in=4995 --max_num_posts=1
copy

This command will generate authentication unique keys and salts in your wp-config.php file.

#wordpress#cli#config
wp config shuffle-salts
copy

List all defined image sizes, their width, height and the crop details.

#wordpress#cli
wp media image-size
copy

Imports WXR files.

#wordpress#cli
wp import yoursiteexample.wordpress.2021-09-22.000.xml
copy

You can import WXR data files to specific site in the multi-site installation. The --url flag identifies the site you want to migrate data to. Skipping authors is optional.

#wordpress#cli#mu
wp import yoursiteexample.wordpress.2021-10-15.000.xml --authors=skip --url=http://yoursite.com/subsite
copy

Install a plugin in your WordPress site. By passing --activate flag you can enable your new plugin in one command.

#wordpress#cli
wp plugin install [pluginhandle] --activate
copy

This command is based on the "wp post list" used to return all posts but the "--post_type=page" flag changes the search scope to return only pages. By default the output if formatted as a table and includes page ID, title, slug, creation date, and the status.

#wordpress#cli
wp post list --post_type=page
copy

Use post ID to return all related meta data. By default it returns data as a table but other formats are available, for example you can use this flag --format=json to get data as json.

#wordpress#cli
wp post meta list <ID>
copy

Returns a table of custom posts with a type specified using the --post_type flag.

#wordpress#cli
wp post list --post_type=movie
copy

Lists all columns in a given database table. You will need to pass a table name as the argument. List of the default WordPress tables - wp_commentmeta, wp_comments, wp_links, wp_options, wp_postmeta, wp_posts, wp_term_relationships, wp_term_taxonomy, wp_termmeta, wp_terms, wp_usermeta, wp_users.

#wordpress#cli#db
wp db columns {tabel name}
copy

Lists all tables in the database connected to your site.

#wordpress#cli#db
wp db tables
copy

Returns a table of all posts including ID, title, name, date and status.

#wordpress#cli
wp post list
copy

If you're running a multi-site WordPress installation you can return a handy table presenting blog ID, URL, and update dates of each site instance.

#wordpress#cli
wp site list
copy

Returns a table of all registered taxonomies including categories, post tags, navigation menus, themes, custom taxonomies and more.

#wordpress#cli
wp taxonomy list
copy

Puts your site in a maintenance mode and returns "Briefly unavailable for scheduled maintenance. Check back in a minute." message with a 503 server response.

#wordpress#cli
wp maintenance-mode activate
copy

Takes your site out of maintenance mode.

#wordpress#cli
wp maintenance-mode deactivate
copy

Returns maintenance mode status of your site.

#wordpress#cli
wp maintenance-mode status
copy

Connects to the database set in your wp-config.php file using MySQL CLI.

#wordpress#cli#db
wp db cli
copy

Runs MySQL optimizer on the connected database.

#wordpress#cli#db
wp db optimize
copy

Regenerate all thumbnail image sizes stored in the media library. The --yes flag confirms your choice.

#wordpress#cli
wp media regenerate --yes
copy

This command will generate basic files and structure for a new plugin. Use --skip-tests flag to omit php unit tests in the process.

#wordpress#cli#plugin
wp scaffold plugin your-plugin-slug
copy

Generates un-styled main theme with all the necessary files and views to display content.

#wordpress#cli
wp scaffold _s your-theme-slug --theme_name="Theme Name" --author="Your Name"
copy

You can search for a string in connected WordPress database. The --stats flag will append details about the search like matches found and tables searched.

#wordpress#cli
wp db search <string_to_find> --stats
copy

Updates all installed plugins.

#wordpress#cli
wp plugin update --all
copy

Update WP-CLI to the latest version.

#wordpress#cli
wp cli update
copy

Prints information to the console about WP CLI and its environment such as version, OS, PHP, MySQL.

#wordpress#cli
wp cli info
copy
NordVPN NordVPN