diff --git a/features/post.feature b/features/post.feature index c3f72a52..078d212e 100644 --- a/features/post.feature +++ b/features/post.feature @@ -395,6 +395,25 @@ Feature: Manage WordPress posts post-2 """ + Scenario: Creating/updating posts with taxonomies + When I run `wp term create category "First Category" --porcelain` + And save STDOUT as {CAT_1} + And I run `wp term create category "Second Category" --porcelain` + And save STDOUT as {CAT_2} + And I run `wp term create post_tag "Term One" --porcelain` + And I run `wp term create post_tag "Term Two" --porcelain` + When I run `wp post create --post_title='Test Post' --post_content='Test post content' --tax_input='{"category":[{CAT_1},{CAT_2}],"post_tag":["term-one", "term-two"]}' --porcelain` + Then STDOUT should be a number + And save STDOUT as {POST_ID} + + When I run `wp post term list {POST_ID} category post_tag --format=table --fields=name,taxonomy` + Then STDOUT should be a table containing rows: + | name | taxonomy | + | First Category | category | + | Second Category | category | + | Term One | post_tag | + | Term Two | post_tag | + Scenario: Update categories on a post When I run `wp term create category "Test Category" --porcelain` Then save STDOUT as {TERM_ID} diff --git a/src/Post_Command.php b/src/Post_Command.php index a4a5ba42..9a3f8748 100644 --- a/src/Post_Command.php +++ b/src/Post_Command.php @@ -186,7 +186,7 @@ public function create( $args, $assoc_args ) { WP_CLI::warning( "The 'meta_input' field was only introduced in WordPress 4.4 so will have no effect." ); } - $array_arguments = [ 'meta_input' ]; + $array_arguments = [ 'meta_input', 'tax_input' ]; $assoc_args = Utils\parse_shell_arrays( $assoc_args, $array_arguments ); if ( isset( $assoc_args['from-post'] ) ) {