Listing posts with wp-cli

I use wp-cli to export some posts from my WordPress database. I’m trying to understand the differences in behavior that are exposed in the example below:

$ wp post list --path=/var/www/home-web --post_type=any --fields=post_name,post_type,post_status
+----------------------------------+------------+-------------+
| post_name                        | post_type  | post_status |
+----------------------------------+------------+-------------+
| background                       | attachment | inherit     |
| privacy-policy                   | page       | publish     |
| macbook_flat_home                | attachment | inherit     |
| engine                           | page       | publish     |
| home                             | page       | publish     |
+----------------------------------+------------+-------------+

$ wp post list --path=/var/www/home-web --post_type=page --fields=post_name,post_type,post_status
+-----------+-----------+-------------+
| post_name | post_type | post_status |
+-----------+-----------+-------------+
| home      | page      | publish     |
+-----------+-----------+-------------+

$ wp post list --path=/var/www/home-web --post_type=polylang_mo --fields=post_name,post_type,post_status
+---------------+-------------+-------------+
| post_name     | post_type   | post_status |
+---------------+-------------+-------------+
| polylang_mo_5 | polylang_mo | private     |
| polylang_mo_2 | polylang_mo | private     |
+---------------+-------------+-------------+

I see two problems:

  • the first request doesn’t show any custom post type (polylang_mo is a custom post type)
  • the second request shows only 1 page (instead of 3)

Note for those unfamiliar with wp-cli: wp post list is basically a wrapper around WP_Query (see source code).

Solutions Collecting From Web of "Listing posts with wp-cli"