@@ -112,7 +112,7 @@ public function __construct() {
112112 * : Array of taxonomy terms keyed by their taxonomy name. Default empty.
113113 *
114114 * [--meta_input=<meta_input>]
115- * : Array of post meta values keyed by their post meta key. Default empty.
115+ * : Array in JSON format of post meta values keyed by their post meta key. Default empty.
116116 *
117117 * [<file>]
118118 * : Read post content from <file>. If this value is present, the
@@ -143,6 +143,10 @@ public function __construct() {
143143 * # Create post with content from given file
144144 * $ wp post create ./post-content.txt --post_category=201,345 --post_title='Post from file'
145145 * Success: Created post 1922.
146+ *
147+ * # Create a post with multiple meta values.
148+ * $ wp post create --post_title='A post' --post_content='Just a small post.' --meta_input='{"key1":"value1","key2":"value2"}
149+ * Success: Created post 1923.
146150 */
147151 public function create ( $ args , $ assoc_args ) {
148152 if ( ! empty ( $ args [0 ] ) ) {
@@ -162,6 +166,9 @@ public function create( $args, $assoc_args ) {
162166 $ assoc_args ['post_category ' ] = explode ( ', ' , $ assoc_args ['post_category ' ] );
163167 }
164168
169+ $ array_arguments = array ( 'meta_input ' );
170+ $ assoc_args = \WP_CLI \Utils \parse_shell_arrays ( $ assoc_args , $ array_arguments );
171+
165172 $ assoc_args = wp_slash ( $ assoc_args );
166173 parent ::_create ( $ args , $ assoc_args , function ( $ params ) {
167174 return wp_insert_post ( $ params , true );
@@ -249,7 +256,7 @@ public function create( $args, $assoc_args ) {
249256 * : Array of taxonomy terms keyed by their taxonomy name. Default empty.
250257 *
251258 * [--meta_input=<meta_input>]
252- * : Array of post meta values keyed by their post meta key. Default empty.
259+ * : Array in JSON format of post meta values keyed by their post meta key. Default empty.
253260 *
254261 * [<file>]
255262 * : Read post content from <file>. If this value is present, the
@@ -268,6 +275,10 @@ public function create( $args, $assoc_args ) {
268275 *
269276 * $ wp post update 123 --post_name=something --post_status=draft
270277 * Success: Updated post 123.
278+ *
279+ * # Update a post with multiple meta values.
280+ * $ wp post update 123 --meta_input='{"key1":"value1","key2":"value2"}
281+ * Success: Updated post 123.
271282 */
272283 public function update ( $ args , $ assoc_args ) {
273284
@@ -285,6 +296,9 @@ public function update( $args, $assoc_args ) {
285296 $ assoc_args ['post_category ' ] = explode ( ', ' , $ assoc_args ['post_category ' ] );
286297 }
287298
299+ $ array_arguments = array ( 'meta_input ' );
300+ $ assoc_args = \WP_CLI \Utils \parse_shell_arrays ( $ assoc_args , $ array_arguments );
301+
288302 $ assoc_args = wp_slash ( $ assoc_args );
289303 parent ::_update ( $ args , $ assoc_args , function ( $ params ) {
290304 return wp_update_post ( $ params , true );
0 commit comments