Created
December 6, 2017 21:05
-
-
Save psorensen/9534b023c09b5b02c7e07c8d14b4e818 to your computer and use it in GitHub Desktop.
Bash script to remove 'uncategorized' term from posts with existing category terms
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 --url={url} ) | |
do | |
count=$(wp post term list $post 'category' --fields='name' --format="count" --url={url} ) | |
if [ "$count" -gt "1" ] | |
then | |
wp post term remove $post category 'uncategorized' --url={url} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment