Skip to content

Instantly share code, notes, and snippets.

@eksiscloud
Created August 2, 2019 22:00
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 eksiscloud/74532991e94d7ef5b343030f12a384ee to your computer and use it in GitHub Desktop.
Save eksiscloud/74532991e94d7ef5b343030f12a384ee to your computer and use it in GitHub Desktop.
Remove uncategorized from Wordpress posts if there is some other category too
#!/bin/bash
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
## chmod 755 remove-category.sh
@eksiscloud
Copy link
Author

You must have WP-CLI installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment