Skip to content

Commit 143b874

Browse files
Add a new flag for getting post meta as a single value or not
1 parent f349e8f commit 143b874

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/WP_CLI/CommandWithMeta.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,15 @@ function ( $a, $b ) use ( $orderby, $order ) {
142142
* <key>
143143
* : The name of the meta field to get.
144144
*
145+
* [--is-single=<is-single>]
146+
* : Whether to return a single value. This parameter has no effect if $key is not specified.
147+
* ---
148+
* default: 1
149+
* options:
150+
* - 1
151+
* - 0
152+
* ---
153+
*
145154
* [--format=<format>]
146155
* : Get value in a particular format.
147156
* ---
@@ -157,7 +166,7 @@ public function get( $args, $assoc_args ) {
157166

158167
$object_id = $this->check_object_id( $object_id );
159168

160-
$value = $this->get_metadata( $object_id, $meta_key, true );
169+
$value = $this->get_metadata( $object_id, $meta_key, $assoc_args['is-single'] );
161170

162171
if ( '' === $value ) {
163172
die( 1 );

0 commit comments

Comments
 (0)