Skip to content

Instantly share code, notes, and snippets.

@lukecav
Created June 28, 2019 18:07
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 lukecav/167a0b92a058188f7f759dad859d5225 to your computer and use it in GitHub Desktop.
Save lukecav/167a0b92a058188f7f759dad859d5225 to your computer and use it in GitHub Desktop.
Remove Tags that Appear in Less than 100 Posts using WP-CLI
for x in $(wp term list post_tag --format=ids) ; do count_posts=$(wp rest post list --tags=$x | wc -l | awk '{print $1-1}'); if [ $count_posts -lt 100 ]; then wp term delete post_tag $x; fi; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment