Skip to content

Instantly share code, notes, and snippets.

@eksiscloud
Last active August 2, 2019 22:08
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/fd3eb0c5b728ae24174ce7d2cd430473 to your computer and use it in GitHub Desktop.
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)
#!/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
@eksiscloud
Copy link
Author

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

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