Skip to content

Instantly share code, notes, and snippets.

@psorensen
Created December 6, 2017 21:05
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 psorensen/9534b023c09b5b02c7e07c8d14b4e818 to your computer and use it in GitHub Desktop.
Save psorensen/9534b023c09b5b02c7e07c8d14b4e818 to your computer and use it in GitHub Desktop.
Bash script to remove 'uncategorized' term from posts with existing category terms
#!/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