You just need to change the syntax of xargs to run multiple commands using the same placeholder:
wp post generate --format=ids --count=10 | sed -e "s/ /\n/g" | xargs -n1 -I % sh -c 'echo "Adding fields for %"; wp post meta add % foo bar; wp post meta add % key_2 value_2';
Update:
The output of wp post generate is post ids with spaces for the delimiter. I’m sure there is a better way for xargs to process spaces but I’m using sed to replace the spaces with newlines.
Reference:
Related Posts:
- Auto Populate Custom Field with Complex Value That Increase by One?
- No result update a custom field using wp_schedule_event
- Automatic linking terms
- How to use custom fields like Title to show value in content?
- ‘Preview Changes’ for custom meta boxes?
- Is there a way to get protected meta fields through any of the available built-in WordPress APIs? (xmlrpc, wp-json)
- Change wp_get_attachment_image attributes (src and srcset) on specific custom field
- Move from old custom field to new post_thumbnails
- How to use custom fields in post title?
- Date, Time, and Timezones
- Making a configurable field translatable
- importing data from non-wordpress mysql db
- Shortest possible shell script to install WordPress on Nginx server?
- Call a custom field in an audio shortcode?
- How to convert custom field value to tag
- Use WP 3.1 Internal Linking ‘widget’ as a meta_box
- Comments form custom fields order
- Is it possible to order posts by two meta values?
- how to save multiple custom fields for a post in one go?
- My metabox class
- ACF won’t load from a custom JSON location
- PODS performance vs custom field
- Custom User Profile Fields
- Custom Fields with get_post()
- How do you create dynamic customised sections in WordPress?
- Get specific custom field keys from a post and put into an array
- Importing from XML is ignoring serialized custom field
- How to check for specific meta box value on front end and output accordingly
- Loop to display random posts only if a custom field matches category
- WP Query Returning All Posts
- WordPress User Profile Upload – If page is saved file reset
- How to add field above password section in profile page
- How can I store a file in the database in the same way WordPress and ACF do?
- Custom Field Create Bulk via SQL Query
- How to add an extra field in a post and show it on the template
- Exclude images uploaded via meta boxes from WordPress gallery
- Front-end editing with custom fields?
- If meta key exists in get posts function otherwise create it
- How do i save and retrieve custom attachment meta?
- Show values of dynamically created custom meta keys
- List taxonomy term “Last Name” + “First Name” (taxonomy custom field) in a post loop
- Filter by custom field (meta_key) using JSON API
- Should custom meta boxes be able to output shortcodes the same as WordPress’ native post editor?
- Bulk append custom field to post content
- Custom fields value
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- More efficient to add content to custom fields or the content area?
- Turn raw url into clickable links
- Advanced Custom Fields functionality without plugin
- Get post ids sorted by meta_key
- Advanced Custom Fields Plugin – Unable to get URL from post_object
- Plot location on Google map using full address specified in custom field
- Display custom field value as a hyperlink
- Unable to get specific value from post meta
- 3.8 Media Upload and Custom Meta Box
- Displaying Custom Field Array
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- IF Custom field value equals ZERO
- Let’s Create Custom Field Template Documentation
- WordPress Settings API Repeatable fields
- Custom Field Repeating When Using foreach
- How to add custom filed value after in wp post title
- If one meta key value is empty, try to get another meta key, and if both meta keys are empty show something else?
- Save attachment ID instead of URL in custom field
- Output custom field as ul list
- How to change permalink on headlines in rss feeds?
- How to order posts by number of Vimeo Likes
- Displaying a video on the homepage via a custom field inside a php widget
- Displaying custom field meta within WP_query loop
- Custom Field Date Problem
- Approach to creating a site with this structure
- how to create meta key name in wp_usermeta table in database
- Display the output from Custom User Fields from a WordPress user profile on a WordPress Custom Page
- get_field values for each post on home page using wp_add_inline_style
- how to turn a link field into a button or link text
- Is there a way to determine which user changed a custom field (and when)?
- Metabox/Custom fields are not saving input data
- Show image depending on the number in the custom fields
- Show echo ready in single.php
- Save, update, get and sanitize post meta as HTML not plain
- Order categories by sum of custom fields
- how to modify a field’s size in a metabox : ROWS height, and scroll control?
- Saved Post Meta Array Returns as String
- Term specific featured post on taxonomy archive pages
- Thirtieth century date for a post
- Saving metadata of related post on save_post
- Custom field in external Javascript
- Custom field value link title
- How to Order Posts by Custom Fields?
- Analyze uploaded images to get colour values
- Turn Current Date in Custom Field Ouput Green or Red
- added a meta box to post however when saving menu while debug on throws a warning
- How can i get the actor birthday by date?
- Make Custom Fields Public in JSON – API
- Advanced Custom Fields for Header that are Editable from a Page [closed]
- Shortcode not picking up custom field
- Order by a meta field in query loop
- Archive for custom fields?
- Search by Custom Field content OR post id via the WordPress Dashboard
- Query ‘orderby’ when there are multiple values for the same meta_key