wp term meta
Overview
Manage custom meta data attached to taxonomy terms, stored in wp_termmeta. Term meta holds plugin-specific settings, ACF custom fields, SEO descriptions, and any key-value data attached to categories, tags, or custom terms.
Subcommands
| Subcommand | Description |
|---|---|
wp term meta get ID KEY | Retrieve a meta value |
wp term meta add ID KEY VALUE | Add new meta |
wp term meta update ID KEY VALUE | Update existing meta |
wp term meta delete ID KEY | Delete a meta key |
wp term meta list ID | List all meta for a term |
wp term meta patch ID KEY SUBKEY VALUE | Update subkey in serialized meta |
wp term meta pluck ID KEY SUBKEY | Read subkey from serialized meta |
Basic Usage
Get a meta value
wp term meta get 12 term_image_url
Add new meta
wp term meta add 12 term_color "#FF5733"
Update existing meta
wp term meta update 12 term_icon "fa-laptop"
Delete meta key
wp term meta delete 12 _temp_flag
List all meta for a term
wp term meta list 12 --format=table
Real-World Scenarios
Scenario 1: Add category images for WooCommerce
for id in $(wp term list product_cat --field=term_id); do
wp term meta add "$id" thumbnail_id "0"
done
Scenario 2: Audit ACF term meta fields
for id in $(wp term list category --field=term_id); do
NAME=$(wp term get category "$id" --field=name)
DESC=$(wp term meta get "$id" _acf_field_description 2>/dev/null)
echo "$NAME: $DESC"
done
Scenario 3: Set term order for custom display
TERMS=($(wp term list category --orderby=name --field=term_id))
POS=1
for id in "${TERMS[@]}"; do
wp term meta update "$id" menu_order "$POS"
((POS++))
done
Best Practices
- Use
listfirst to see existing meta before adding duplicates. - Prefix custom meta keys (e.g.
_mysite_color) to avoid plugin conflicts. - Use
patchfor serialized or array meta values.
Quick Reference
wp term meta get <id> <key> # Get value
wp term meta add <id> <key> <value> # Add new
wp term meta update <id> <key> <value> # Update
wp term meta delete <id> <key> # Delete
wp term meta list <id> --format=table # All meta
Next Steps
wp term get— retrieve core term fields.wp term update— update standard term fields.wp post meta— manage post meta fields.