I need to generate a CSV report with information that is stored into a few custom fields of a custom post type. How do I list just the content of these custom fields, for all — or a subset — of these custom post types?
(I'm trying to use wp-cli to achieve this, because it's an extremely powerful and versatile tool that never failed me before. Sorry if I'm approaching it as an "X-Y problem"!)
For now all I got is
wp post list --post_type=<MYCPT> --posts_per_page=1 to get me the most recent post, and then
wp post meta list <ID> with the ID returned in the previous command.
This lists me all the custom fields for a single custom post. What I need, however, is the content of just a few custom fields, for all custom posts of this type.
I suppose I can write a bash script to iterate through everything and grep just the custom fields I want, but is there an easier way?