WordPress – Working with CLI

Inhaltsverzeichnis [Anzeigen]

Working with CLI

Basic work with posts

Search post content.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post list --s="text" --fields=ID,post_title,url
wp post list --s="text" --fields=ID,post_title,url
wp post list --s="text" --fields=ID,post_title,url

Find posts with ping status “open”.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post list --ping_status="open"
wp post list --ping_status="open"
wp post list --ping_status="open"

And if you only want to get the post IDs:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post list --ping_status="open" --fields=ID
wp post list --ping_status="open" --fields=ID
wp post list --ping_status="open" --fields=ID

Update ping status to “closed” where the value is “open”.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post update $(wp post list --ping_status="open" --format=ids) --ping_status="closed";
wp post update $(wp post list --ping_status="open" --format=ids) --ping_status="closed";
wp post update $(wp post list --ping_status="open" --format=ids) --ping_status="closed";

Search and replace

Search and replace post content.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp search-replace "old thing" "new thing" --all-tables
bashwp search-replace "old thing" "new thing" --all-tables
bashwp search-replace "old thing" "new thing" --all-tables

Post meta

List all metadata associated with a post.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post meta list 1422 --format=json
bashwp post meta list 1422 --format=json
bashwp post meta list 1422 --format=json

Get specific post meta for a post.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post meta get 1422 "meta_key" --format=json
bashwp post meta get 1422 "meta_key" --format=json
bashwp post meta get 1422 "meta_key" --format=json

Update post meta.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post meta update 1422 "meta_key" "meta_value"
bashwp post meta update 1422 "meta_key" "meta_value"
bashwp post meta update 1422 "meta_key" "meta_value"

Update post meta from a file.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post meta update 1422 "post_meta" < file.json --format=json
bashwp post meta update 1422 "post_meta" < file.json --format=json
bashwp post meta update 1422 "post_meta" < file.json --format=json

Delete post meta.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post meta delete 1422 "post_meta"
bashwp post meta delete 1422 "post_meta"
bashwp post meta delete 1422 "post_meta"

Delete all post meta by specific key. (With wp db query.)

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp db query "DELETE FROM `wp_postmeta` WHERE `meta_key` = 'NAME_OF_YOUR_META_KEY'"
bashwp db query "DELETE FROM `wp_postmeta` WHERE `meta_key` = 'NAME_OF_YOUR_META_KEY'"
bashwp db query "DELETE FROM `wp_postmeta` WHERE `meta_key` = 'NAME_OF_YOUR_META_KEY'"

List posts by meta key or value.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post list --fields=ID,post_title,url --meta_key="meta_key"
wp post list --fields=ID,post_title,url --meta_key="meta_key" --meta_compare="NOT EXISTS"
wp post list --post_type="post_type" --fields=ID,post_title,url --meta_key="meta_key" --meta_compare="NOT EXISTS"
wp post list --fields=ID,post_title,url --meta_key="_wp_page_template" --meta_value="page-templates/post-full-grid.php"
bashwp post list --fields=ID,post_title,url --meta_key="meta_key" wp post list --fields=ID,post_title,url --meta_key="meta_key" --meta_compare="NOT EXISTS" wp post list --post_type="post_type" --fields=ID,post_title,url --meta_key="meta_key" --meta_compare="NOT EXISTS" wp post list --fields=ID,post_title,url --meta_key="_wp_page_template" --meta_value="page-templates/post-full-grid.php"
bashwp post list --fields=ID,post_title,url --meta_key="meta_key"
wp post list --fields=ID,post_title,url --meta_key="meta_key" --meta_compare="NOT EXISTS"
wp post list --post_type="post_type" --fields=ID,post_title,url --meta_key="meta_key" --meta_compare="NOT EXISTS"
wp post list --fields=ID,post_title,url --meta_key="_wp_page_template" --meta_value="page-templates/post-full-grid.php"

The meta_compare flag also accepts "LIKE" as a value, so that you can do:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
phpwp post list --fields=ID,post_title,url --meta_key='meta_key' --meta_compare='LIKE' --meta_value='value'
phpwp post list --fields=ID,post_title,url --meta_key='meta_key' --meta_compare='LIKE' --meta_value='value'
phpwp post list --fields=ID,post_title,url --meta_key='meta_key' --meta_compare='LIKE' --meta_value='value'

Update meta where it’s missing.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post meta update $(wp post list --post_type="post_type" --meta_key="meta_key" --meta_compare="NOT EXISTS" --format=ids) "meta_key" "meta_value"
bashwp post meta update $(wp post list --post_type="post_type" --meta_key="meta_key" --meta_compare="NOT EXISTS" --format=ids) "meta_key" "meta_value"
bashwp post meta update $(wp post list --post_type="post_type" --meta_key="meta_key" --meta_compare="NOT EXISTS" --format=ids) "meta_key" "meta_value"

Update post meta for all posts in a category.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post meta update $(wp post list --category_name="category" --format=ids) "meta_key" "meta_value"
bashwp post meta update $(wp post list --category_name="category" --format=ids) "meta_key" "meta_value"
bashwp post meta update $(wp post list --category_name="category" --format=ids) "meta_key" "meta_value"

Save meta value based on an existing meta value. In this example I’m looping through all post with a specific post type and saving the URL of the featured image to the post’s meta.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashfor id in $(wp post list --post_type="post_type" --fields=ID --meta_key="meta_key" --meta_compare="NOT EXISTS")
do
wp post meta update $id "meta_key" $(wp post meta pluck $(wp post meta get $id _thumbnail_id) _wp_attachment_metadata file)
done
bashfor id in (wppostlistposttype="posttype"fields=IDmetakey="metakey"metacompare="NOTEXISTS")dowppostmetaupdateid "meta_key" (wppostmetapluck(wp post meta get $id _thumbnail_id) _wp_attachment_metadata file) done
bashfor id in $(wp post list --post_type="post_type" --fields=ID --meta_key="meta_key" --meta_compare="NOT EXISTS")
do
    wp post meta update $id "meta_key" $(wp post meta pluck $(wp post meta get $id _thumbnail_id) _wp_attachment_metadata file)
done

Show specific meta value for posts based on a category.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashfor id in $(wp post list --post_type="post_type" --fields=ID --category="category name")
do
wp post meta get $id "meta_key"
done
bashfor id in (wppostlistposttype="posttype"fields=IDcategory="categoryname")dowppostmetagetid "meta_key" done
bashfor id in $(wp post list --post_type="post_type" --fields=ID --category="category name")
do
    wp post meta get $id "meta_key"
done

Export/import all meta.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post meta list 1422 --format=json > 1422_meta.json
wp post update 1422 --meta_input= < 1422_meta.json
bashwp post meta list 1422 --format=json > 1422_meta.json wp post update 1422 --meta_input= < 1422_meta.json
bashwp post meta list 1422 --format=json > 1422_meta.json
wp post update 1422 --meta_input= < 1422_meta.json

Working with post terms

Move posts from one tag to another.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashfor id in $(wp post list --tag=OLD_TAG --format=ids)
do
wp post term remove $id post_tag OLD_TAG --by=slug
wp post term add $id post_tag NEW_TAG --by=slug
done
bashfor id in (wppostlisttag=OLDTAGformat=ids)dowpposttermremoveid post_tag OLD_TAG --by=slug wp post term add $id post_tag NEW_TAG --by=slug done
bashfor id in $(wp post list --tag=OLD_TAG --format=ids)
do
    wp post term remove $id post_tag OLD_TAG --by=slug
    wp post term add $id post_tag NEW_TAG --by=slug
done

Delete Posts

Delete all posts from a custom post type. (Adding --force will skip the trash and remove the posts completely.)

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post delete $(wp post list --post_type='activity' --format=ids) --force
bashwp post delete $(wp post list --post_type='activity' --format=ids) --force
bashwp post delete $(wp post list --post_type='activity' --format=ids) --force

If you’re trying to delete too many posts at once, you might get an error like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashPHP Fatal error: Allowed memory size of xxx bytes exhausted
bashPHP Fatal error: Allowed memory size of xxx bytes exhausted
bashPHP Fatal error: Allowed memory size of xxx bytes exhausted

Or perhaps this one:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashArgument list too long
bashArgument list too long
bashArgument list too long

One way around this is to limit how many posts you’re deleting at once using the posts_per_page option, for example:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post delete $(wp post list --post_type='activity' --posts_per_page=50000 --format=ids) --force
bashwp post delete $(wp post list --post_type='activity' --posts_per_page=50000 --format=ids) --force
bashwp post delete $(wp post list --post_type='activity' --posts_per_page=50000 --format=ids) --force

Delete posts with specific meta key.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post delete $(wp post list --format=ids --meta_key="meta_key")
bashwp post delete $(wp post list --format=ids --meta_key="meta_key")
bashwp post delete $(wp post list --format=ids --meta_key="meta_key")

Delete posts with specific meta key and meta value.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post delete $(wp post list --format=ids --meta_key="meta_key" --meta_value="meta_value")
bashwp post delete $(wp post list --format=ids --meta_key="meta_key" --meta_value="meta_value")
bashwp post delete $(wp post list --format=ids --meta_key="meta_key" --meta_value="meta_value")

Delete posts where a specific meta key is missing.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post delete $(wp post list --format=ids --meta_key="meta_key" --meta_compare="NOT EXISTS")
bashwp post delete $(wp post list --format=ids --meta_key="meta_key" --meta_compare="NOT EXISTS")
bashwp post delete $(wp post list --format=ids --meta_key="meta_key" --meta_compare="NOT EXISTS")

Post revisions

List all revisions.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post list --post_type=revision
bashwp post list --post_type=revision
bashwp post list --post_type=revision

List revisions for a specific post.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp post list --post_parent=1422 --post_type=revision
bashwp post list --post_parent=1422 --post_type=revision
bashwp post list --post_parent=1422 --post_type=revision

Get more info on revisions for a specific post.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashfor id in $(wp post list --post_parent=1422 --post_type=revision --fields=ID)
do
wp post get $id
done
bashfor id in (wppostlistpostparent=1422posttype=revisionfields=ID)dowppostgetid done
bashfor id in $(wp post list --post_parent=1422 --post_type=revision --fields=ID)
do
    wp post get $id
done

Site Options

Change the site URL.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp option update home 'https://example.com'
wp option update siteurl 'https://example.com'
bashwp option update home 'https://example.com' wp option update siteurl 'https://example.com'
bashwp option update home 'https://example.com'
wp option update siteurl 'https://example.com'

Plugins

List active plugins.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp plugin list --status=active
bashwp plugin list --status=active
bashwp plugin list --status=active

Activate/deactivate plugins.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bashwp plugin activate plugin-1 plugin-2 plugin-3
wp plugin deactivate plugin-1 plugin-2 plugin-3
bashwp plugin activate plugin-1 plugin-2 plugin-3 wp plugin deactivate plugin-1 plugin-2 plugin-3
bashwp plugin activate plugin-1 plugin-2 plugin-3
wp plugin deactivate plugin-1 plugin-2 plugin-3

Users

Update user password.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp user update USER_ID --user_pass="newpassword"
wp user update USER_ID --user_pass="newpassword"
wp user update USER_ID --user_pass="newpassword"

WP CLI cheatsheet

check database size

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

Reference:https://developer.wordpress.org/cli/commands/db/size/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp db size --human-readable --tables
wp db size --human-readable --tables
wp db size --human-readable --tables

 copy

check db status

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

Reference:https://developer.wordpress.org/cli/commands/db/check/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp db check
wp db check
wp db check

 copy

check for updates

Checks if WP-CLI is due for an update.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp cli check-update
wp cli check-update
wp cli check-update

 copy

check version

Return WP CLI version.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp cli version
wp cli version
wp cli version

 copy

configure wordpress

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp config create --dbname=yourdbname --dbuser=root --prompt=dbpassword
wp config create --dbname=yourdbname --dbuser=root --prompt=dbpassword
wp config create --dbname=yourdbname --dbuser=root --prompt=dbpassword

 copy

count all posts

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

Reference:https://developer.wordpress.org/cli/commands/post/list/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post list --format=count
wp post list --format=count
wp post list --format=count 

 copy

download wordpress

Download latest version of WordPress core files to current directory.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp core download
wp core download
wp core download

 copy

edit config

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp config edit
wp config edit
wp config edit

 copy

export

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.

Reference:https://developer.wordpress.org/cli/commands/export/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp export
wp export
wp export

 copy

export single page

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.

Reference:https://developer.wordpress.org/cli/commands/export/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp export --skip_comments --post_type=page --post__in=4995 --max_num_posts=1
wp export --skip_comments --post_type=page --post__in=4995 --max_num_posts=1
wp export --skip_comments --post_type=page --post__in=4995 --max_num_posts=1

 copy

generate salts

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

Reference:https://developer.wordpress.org/cli/commands/config/shuffle-salts/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp config shuffle-salts
wp config shuffle-salts
wp config shuffle-salts

 copy

get media image sizes

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

Reference:https://developer.wordpress.org/cli/commands/media/image-size/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp media image-size
wp media image-size
wp media image-size

 copy

import

Imports WXR files.

Reference:https://developer.wordpress.org/cli/commands/import/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp import yoursiteexample.wordpress.2021-09-22.000.xml
wp import yoursiteexample.wordpress.2021-09-22.000.xml
wp import yoursiteexample.wordpress.2021-09-22.000.xml

 copy

import to sub-site

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.

Reference:https://developer.wordpress.org/cli/commands/import/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp import yoursiteexample.wordpress.2021-10-15.000.xml --authors=skip --url=http://yoursite.com/subsite
wp import yoursiteexample.wordpress.2021-10-15.000.xml --authors=skip --url=http://yoursite.com/subsite
wp import yoursiteexample.wordpress.2021-10-15.000.xml --authors=skip --url=http://yoursite.com/subsite

 copy

install plugin

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp plugin install [pluginhandle] --activate
wp plugin install [pluginhandle] --activate
wp plugin install [pluginhandle] --activate

 copy

list all pages

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.

Reference:https://developer.wordpress.org/cli/commands/post/list/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post list --post_type=page
wp post list --post_type=page
wp post list --post_type=page

 copy

list all post meta

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.

Reference:https://developer.wordpress.org/cli/commands/post/meta/list/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post meta list <ID>
wp post meta list <ID>
wp post meta list <ID>

 copy

list custom post type

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

Reference:https://developer.wordpress.org/cli/commands/post/list/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post list --post_type=movie
wp post list --post_type=movie
wp post list --post_type=movie

 copy

list database table columns

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.

Reference:https://developer.wordpress.org/cli/commands/db/columns/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp db columns {tabel name}
wp db columns {tabel name}
wp db columns {tabel name}

 copy

list database tables

Lists all tables in the database connected to your site.

Reference:https://developer.wordpress.org/cli/commands/db/tables/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp db tables
wp db tables
wp db tables

 copy

list post types

Returns a table of all post types including custom posts.

Reference:https://developer.wordpress.org/cli/commands/post-type/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post-type list
wp post-type list
wp post-type list

 copy

list posts

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

Reference:https://developer.wordpress.org/cli/commands/post/list/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp post list
wp post list
wp post list

 copy

list sites

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.

Reference:https://developer.wordpress.org/cli/commands/site/list/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp site list
wp site list
wp site list

 copy

list taxonomies

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

Reference:https://developer.wordpress.org/cli/commands/taxonomy/list/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp taxonomy list
wp taxonomy list
wp taxonomy list

 copy

maintenance-mode activate

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.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp maintenance-mode activate
wp maintenance-mode activate
wp maintenance-mode activate

 copy

maintenance-mode deactivate

Takes your site out of maintenance mode.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp maintenance-mode deactivate
wp maintenance-mode deactivate
wp maintenance-mode deactivate

 copy

maintenance-mode status

Returns maintenance mode status of your site.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp maintenance-mode status
wp maintenance-mode status
wp maintenance-mode status

open mysql cli

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

Reference:https://developer.wordpress.org/cli/commands/db/cli/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp db cli
wp db cli
wp db cli

optimize database

Runs MySQL optimizer on the connected database.

Reference:https://developer.wordpress.org/cli/commands/db/optimize/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp db optimize
wp db optimize
wp db optimize

regenerate thumbnails

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

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp media regenerate --yes
wp media regenerate --yes
wp media regenerate --yes

 copy

scaffold plugin

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

Reference:https://developer.wordpress.org/cli/commands/scaffold/plugin/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp scaffold plugin your-plugin-slug
wp scaffold plugin your-plugin-slug
wp scaffold plugin your-plugin-slug

 copy

scaffold theme

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

Reference:https://developer.wordpress.org/cli/commands/scaffold/_s/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp scaffold _s your-theme-slug --theme_name="Theme Name" --author="Your Name"
wp scaffold _s your-theme-slug --theme_name="Theme Name" --author="Your Name"
wp scaffold _s your-theme-slug --theme_name="Theme Name" --author="Your Name"

 copy

search string in DB

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.

Reference:https://developer.wordpress.org/cli/commands/db/search/

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp db search <string_to_find> --stats
wp db search <string_to_find> --stats
wp db search <string_to_find> --stats

update all plugins

Updates all installed plugins.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp plugin update --all
wp plugin update --all
wp plugin update --all

update wp-cli

Update WP-CLI to the latest version.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
wp cli update
wp cli update
wp cli update

wp-cli info

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