wp term delete
Overview
Permanently remove one or more taxonomy terms from WordPress. Posts assigned to the deleted term will have that term removed from their assignments.
What It Does
wp term delete calls wp_delete_term() for each specified term ID. Posts are not deleted — they simply lose the term assignment.
Syntax
wp term delete <taxonomy> <term-id>...
Basic Usage
Delete a category by ID
wp term delete category 12
Delete multiple terms
wp term delete post_tag 33 34 35
Real-World Scenarios
Scenario 1: Delete all empty categories
for id in $(wp term list category --hide_empty=false --field=term_id); do
COUNT=$(wp term get category "$id" --field=count)
if [[ "$COUNT" -eq 0 ]]; then
wp term delete category "$id"
echo "Deleted empty category ID $id"
fi
done
Scenario 2: Delete unused WooCommerce tags after product cleanup
for id in $(wp term list product_tag --hide_empty=false --field=term_id); do
COUNT=$(wp term get product_tag "$id" --field=count)
if [[ "$COUNT" -eq 0 ]]; then
wp term delete product_tag "$id"
fi
done
Best Practices
Content impact
Deleting a term unlinks it from all posts. Posts remain, but the term assignment is removed. If "Uncategorized" is the default category, WordPress prevents its deletion.
- Check post count first —
wp term get TAXONOMY ID --field=countbefore deleting. - Reassign posts to another term before deleting if you want content to remain categorized.
Quick Reference
wp term delete <taxonomy> <id> # Delete one term
wp term delete <taxonomy> 12 15 22 # Delete multiple
wp term list <taxonomy> --format=table # List before deleting
Next Steps
wp term list— find term IDs to delete.wp post term— reassign posts to different terms first.