I regularly need to create a batch of posts of a custom post type, with names and meta values that follow a regular pattern. This seems like a perfect canditate for using wp-cli, but so far it hasn't worked.

Using wp-cli, if I enter:

wp post create --post_title='test' --post_status='draft' post_type='class_notes'

I get an error:

Unable to read content from 'post_type=class_notes'.

However wp-cli is definitely able to connect to this post type, as the following returns a proper list of labels and capabilities:

wp post-type get 'class_notes'

Is it the case that I simply cannot create a post with a custom post type using wp-cli?

2 Answers 2


It should probably be

wp post create --post_title='test' --post_status='draft' --post_type='class_notes'

(note the two -- that mark it as a command option)

  • Ah, you got it. Thanks so much. My face is a little red now. Sep 17, 2018 at 4:07

You can also use https://developer.wordpress.org/cli/commands/post/generate/ to generate how posts you need (for testing purpose for example)

  • Thanks for the suggestion. That's not really a direct answer to what I was trying to do, but it's a useful resource all the same. Dec 31, 2021 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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