Automate WordPress with WP-CLI commands! Introducing how to use WP-CLI. You can execute WordPress installation, updates, posts, media, SQL, DB, child theme creation, and more via commands.
WordPress Operation Commands
The following command downloads WordPress with wp-cli.
wp core download --locale=nl_NL
The following command installs WordPress with wp-cli.
wp core install --url=example.com --title=Example --admin_user=supervisor --admin_password=strongpassword [email protected]
The following command installs without entering a password.
wp core install --url=example.com --title=Example --admin_user=supervisor [email protected] --prompt=admin_password < admin_password.txt
The following command updates WordPress.
wp core update
Forcefully downgrade version The following command forcefully downgrades the WordPress version.
wp core update --version=3.1 --force
show version The following command displays the WordPress version.
wp core version --extra
The following command updates a post.
wp post update 80 --post_status=Publish --post_content="foo"
Media Commands
The following command imports images.
wp media import ~/Pictures/**\/*.jpg
The following command imports images from a URL.
wp media import https://s.w.org/style/images/wp-header-logo.png --title='The WordPress logo' --alt="Semantic personal publishing"
SQL/Database Commands
The following command executes SQL.
wp db query 'SELECT * FROM wp_options WHERE option_name="home"' --skip-column-names
The following command displays tables.
wp db tables --scope=blog --url=sub.example.com
Generating from Templates
The following command creates a child-theme.
wp scaffold child-theme sample-theme --parent_theme=twentysixteen
wp scaffold | WP-CLI Command | WordPress Developer Resources
Reference: