Created
June 28, 2019 18:09
-
-
Save lukecav/61258f258d543c6c018de60de176d5df to your computer and use it in GitHub Desktop.
Remove “Uncategorized” from Posts with More than One Category using 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
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