WP-CLI – Return posts with matching meta key

Managed to figure this out, you can pass –meta_key and –meta_compare arguments like this…

wp post list --fields=ID,mycustomfield --meta_key=mycustomfield '--meta_compare=active'

ID   |  mycustomfield
-----------------------
 1    |  active
 2    |  active
 4    |  active

Leave a Comment