Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created June 28, 2019 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/61258f258d543c6c018de60de176d5df to your computer and use it in GitHub Desktop.
Save lukecav/61258f258d543c6c018de60de176d5df to your computer and use it in GitHub Desktop.
Remove “Uncategorized” from Posts with More than One Category using WP-CLI
for post in $(wp post list --field=ID); do count=$(wp post term list $post 'category' --fields='name' --format="count"); if [ "$count" -gt "1" ]; then wp post term remove $post category 'uncategorized'; fi; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment