Skip to content

Instantly share code, notes, and snippets.

@fernandovbs
Forked from lukecav/Commands
Created December 1, 2022 15:01
Show Gist options
  • Save fernandovbs/e5dfc3b92649dd0773fa234a575e97d5 to your computer and use it in GitHub Desktop.
Save fernandovbs/e5dfc3b92649dd0773fa234a575e97d5 to your computer and use it in GitHub Desktop.
Bulk update all product posts in WooCommerce with a post status of publish or draft using a WP-CLI command
# Bulk update all product posts with a post status of publish to draft
wp post list --field=ID --post_type=product --posts_per_page=500 --post_status=publish | xargs wp post update --post_status=draft
# Bulk update all product posts with a post status of draft to publish
wp post list --field=ID --post_type=product --posts_per_page=500 --post_status=draft | xargs wp post update --post_status=publish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment