Skip to main content

wp post term

Overview

Manage the relationship between posts and taxonomy terms (categories, tags, custom taxonomies). Add, remove, or completely replace a post's terms in a single command.

Subcommands

SubcommandDescription
wp post term add ID TAXONOMY TERM...Add terms to a post
wp post term set ID TAXONOMY TERM...Replace all terms with specified ones
wp post term remove ID TAXONOMY TERM...Remove specific terms
wp post term list ID TAXONOMYList terms assigned to a post

Basic Usage

Add category to a post (by slug)

wp post term add 42 category technology science

Set tags — replace existing

wp post term set 42 post_tag wordpress wpcli automation

Remove a category

wp post term remove 42 category uncategorized

List current terms

wp post term list 42 category --format=table

Real-World Scenarios

Scenario 1: Tag all published posts with a campaign tag

for id in $(wp post list --post_status=publish --post_type=post --field=ID); do
wp post term add "$id" post_tag "campaign-2026"
done

Scenario 2: Remove "Uncategorized" from all posts after recategorizing

for id in $(wp post list --post_type=post --post_status=publish --field=ID); do
wp post term remove "$id" category uncategorized
done

Scenario 3: Set product category for WooCommerce items

for id in $(wp post list --post_type=product --field=ID); do
wp post term add "$id" product_cat "featured"
done

Quick Reference

wp post term add <id> <taxonomy> <term>...    # Add term(s)
wp post term set <id> <taxonomy> <term>... # Replace all terms
wp post term remove <id> <taxonomy> <term> # Remove term
wp post term list <id> <taxonomy> # List terms on post

Next Steps