How do I pass an array as an argument to a WP-CLI command?

This is probably impossible since WP-CLI pass the arguments directly to wp_insert_posts. I’m automating this with wp eval. For example:

wp eval 'wp_set_object_terms(12 , array(1, 2, 3), "course");'

The post id can be obtained when you create the post with --porcelain:

wp post create ... --porcelain

Or by normal query with post title:

wp eval 'wp_set_object_terms(get_page_by_title("Test Post #1", OBJECT, "lecture")->ID, array(1, 2, 3), "course");'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)