wp term get
Overview
Inspect a single taxonomy term — ID, slug, description, parent, count, and more. Use this before updating, assigning to posts, or scripting conditional logic on terms.
What It Does
wp term get calls get_term_by() and returns the term object fields. You can reference the term by its ID or slug.
Syntax
wp term get <taxonomy> <term> [OPTIONS]
TERM can be a term ID or slug.
Arguments & Options
| Flag | Description |
|---|---|
--by=FIELD | Identifier type: term_id (default) or slug |
--field=FIELD | Return one field value |
--fields=FIELDS | Return specific fields |
--format=FORMAT | table, json, yaml, csv |
Basic Usage
Get by slug
wp term get category technology --by=slug
Get by ID
wp term get category 12
Get a single field
wp term get category technology --by=slug --field=term_id
Real-World Scenarios
Get term ID for scripting
TERM_ID=$(wp term get category technology --by=slug --field=term_id)
wp post term add 42 category $TERM_ID
Check a term's post count
COUNT=$(wp term get post_tag wordpress --by=slug --field=count)
echo "Posts tagged 'wordpress': $COUNT"
Quick Reference
wp term get <taxonomy> <id> # By ID
wp term get <taxonomy> <slug> --by=slug # By slug
wp term get <taxonomy> <term> --field=term_id # ID only
wp term get <taxonomy> <term> --format=json # JSON
Next Steps
wp term update— edit the term.wp term list— list all terms in a taxonomy.wp post term— assign this term to posts.