WP CLI Command - xwp/stream GitHub Wiki
Description
Since version 2.0.3
there is a custom WP-CLI command available for querying records via the command line.
The query
subcommand can accept any available query parameter as an argument.
Basic Usage
$ wp stream query
$ wp stream query --author=1
$ wp stream query --author_role__not_in=administrator --date_after=2015-01-01T12:00:00
$ wp stream query --author=1 --action=login --records_per_page=50 --fields=created --order=asc
Fields
You can use the fields
argument to fetch only the portions of the record that you are interested in.
Fields will be displayed in the output in the same order that you place them into the argument.
Example:
$ wp stream query --fields=created,author,ip,summary
If the fields
argument is undefined the default output will be:
created
ip
author
author_meta.user_login
author_role
summary
Notice that you can get specific fields from within an object field by using a .
(dot).
You can override the default fields
output using the wp-cli.yml
configuration file in your project:
stream query:
fields: created,summary,author_meta.user_login
Format
As of 2.0.4
there is also a reserved format
argument available to change the output of the query results.
table
(default) - Displays results in ASCII table formatcount
- Displays only the number of results foundjson
- Displays results in raw JSON formatjson_pretty
- Displays results in a readable JSON format with whitespacecsv
- Displays results in CSV format
Examples:
$ wp stream query --format=count
$ wp stream query --author=1 --format=json