entity-command icon indicating copy to clipboard operation
entity-command copied to clipboard

Support non unique meta_keys when getting values

Open grappler opened this issue 4 years ago • 2 comments

Feature Request

Describe your use case and the problem you are facing

Post meta can either be unique or non single. This means that the same meta key can be used multiple times in post meta. When using get_post_meta() you can pass if the meta key is single or not.

Unfortunately wp post meta 1 meta_key does not support this. At the moment only the first value is returned.

Describe the solution you'd like

This is caused by the fixed defined parameter in the code: https://github.com/wp-cli/entity-command/blob/6e0e77a297eefa3329b94bec16c15cf7528d343f/src/WP_CLI/CommandWithMeta.php#L161

It would be nice if the third parameter could be either set using the arguments or using a flag. Either wp post meta 1 meta_key false or wp post meta 1 meta_key --is-single=false.

grappler avatar Aug 05 '21 21:08 grappler

I'm open to a pull request for this. I don't have any great ideas on what the default format should be, though

https://github.com/wp-cli/entity-command/issues/142 should probably be considered in tandem.

danielbachhuber avatar Apr 26 '23 18:04 danielbachhuber

Hii @danielbachhuber I would like to work on this issue. I think adding a extra flag seems reasonable for this. Default should be false and we show multiple values if we find them.

Your thoughts?

imrraaj avatar Jun 25 '24 12:06 imrraaj