Skip to content

Instantly share code, notes, and snippets.

@allysonsouza
Last active February 18, 2019 23:40
Show Gist options
  • Select an option

  • Save allysonsouza/f84e6301ee1457025facbeda7c8fd085 to your computer and use it in GitHub Desktop.

Select an option

Save allysonsouza/f84e6301ee1457025facbeda7c8fd085 to your computer and use it in GitHub Desktop.
WP-CLI Tricks
## Output posts into post.txt file, only ID
wp post list --post_type=shop_order --field=ID --format=table > posts.txt
## Loop trough each post ID stored in posts.txt then run some wp-cli command, like post meta update
## Change the two %p for %%p if you want to run it in a .bat file (I run it directly on cmd)
FOR /F "tokens=1* delims=" %p IN (posts.txt) DO wp post meta update %p my_meta_key "My Value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment