Unlock Hidden Powers: Transform Your WordPress Workflow with WP-CLI Today!

Unlock Hidden Powers: Transform Your WordPress Workflow with WP-CLI Today!
wp post update $(wp post list --author=1 --format=ids) --post_author=2
WP-CLI-wp-post-update-list

This command retrieves a list of all posts authored by the author with author ID 1, then updates or changes them so that the author is now the one with ID 2.

You could use the same approach to change the status of all published posts to draft by using this command:

wp post update $(wp post list --post_status=publish --format=ids) --post_status=draft

You can see what else is possible with this command on the wp post update page of the WP-CLI documentation.

wp post delete

Deleting posts is another task that you can carry out with WP-CLI.

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38