Since there are a lot of functions that are supported by WP-CLI, there are separate commands to execute each action. But most of them are straight forward. For example, the ‘wp admin
’ command opens your admin area in the web browser whereas the ‘wp config
’ command generates and reads the wp-config.php
file.
Some commands have subcommands which allow you to fine-tune your query.
For example, the ‘wp post
’ command allows you to list, create, list, and delete a post. But to perform each of this action, you need to use different subcommands –
wp post create
to create a new post.wp post delete
to delete one or more posts.wp post list
to get a list of posts.Here is a list of all the built-in WP-CLI Commands.
Examples
You can use ‘wp help <command-name>
’ to get more information and list of sub-commands. For example, ‘wp help post
‘ will display information and list of sub-commands of post command. You can also use it get information sub-command. For example, ‘wp help post list
‘.
Using WP-CLI’s ‘wp db
’ command, you can even export or import your database right from the terminal. Have a look at the below subcommands to read more about them.
wp db export
– Exports the database to a file or to STDOUT.wp db import
– Imports a database from a file or from STDIN.