Last active
August 2, 2019 22:08
-
-
Save eksiscloud/fd3eb0c5b728ae24174ce7d2cd430473 to your computer and use it in GitHub Desktop.
Poistaa Wordpress-artikkelista oletusluokan Yleinen, jos artikkelilla on vähintään yksi toinenkin luokka (WP-CLI)
This file contains 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 'yleinen' | |
fi | |
done | |
## chmod 755 poista-yleinen.sh | |
## tarvitset WP-CLI:n asennettuna |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Removes uncategorized from Wordpress posts if there is some other category too. This one is fi_FI localized version... ;)
Really, just change 'yleinen' in $post category for any category you want.
This is same as this english one:
https://gist.github.com/eksiscloud/74532991e94d7ef5b343030f12a384ee