Since there are a lot of functions that we can perform by WP-CLI, there are separate commands to execute each action, but most of them are straightforward.
For example:
wp admin command opens your admin area in the web browser.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, and delete a post. But to perform each of these actions, you need to use different sub-commands.
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.All the commands accept some global parameters, which provide some configurational arguments to the commands when executed.
For example:
You can find references to all global parameters here.
Apart from global parameters, each command has its own set of parameters, which could be used to configure the command’s arguments.
For example:
wp db export --tables=wp_options,wp_users; here, using the tables parameter, we specified to export only the wp_options and wp_users tables from the database.You can find the reference for all command-specific parameters from each command, like for db export. If you want to know about any command from the CLI terminal itself, there is a command for that too.
wp help commandNameFor example, wp help user will show all details, subcommands, and arguments supported by the user command here.
Here is a list of all the built-in WP-CLI commands. Make sure you go through all of them!
More Examples
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.Watch the following videos to get an insight into built-in commands and global parameters:
Go through the subcommands and their options of the following commands Also try them locally!