3

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).

  • Regarding the first question, I suspect this is because polylang_mo is a private custom post type. Unless I explicitly request this post type, it won't be included. – Warren Seine Apr 29 '16 at 8:39
  • And regarding the second, --skip-plugins=polylang solved it. I'll create an answer. Rubber ducking always works. – Warren Seine Apr 29 '16 at 9:09
4

the first request doesn't show any custom post type (polylang_mo is a custom post type)

polylang_mo is a private custom post type so unless I explicitly request this post type, it won't be included.

the second request shows only 1 page (instead of 3)

Polylang was actually filtering the results. Adding --skip-plugins=polylang makes the 3 posts appear.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.