Created
August 2, 2019 22:00
-
-
Save eksiscloud/74532991e94d7ef5b343030f12a384ee to your computer and use it in GitHub Desktop.
Remove uncategorized from Wordpress posts if there is some other category too
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You must have WP-CLI installed