wp term list
Overview
Query and list all terms in any WordPress taxonomy — built-in or custom. Filter, sort, and export for auditing, scripting, and content management.
What It Does
wp term list calls get_terms() and outputs term data for a given taxonomy.
Syntax
wp term list <taxonomy> [OPTIONS]
Arguments & Options
| Flag | Description |
|---|---|
--fields=FIELDS | Fields: term_id, name, slug, count, parent |
--field=FIELD | Single field per line (for scripting) |
--format=FORMAT | table, json, csv, ids |
--hide_empty | Exclude terms with no posts (default: false) |
--orderby=FIELD | name, count, slug |
--order=ASC_OR_DESC | Sort direction |
--number=N | Max number of terms |
--search=TERM | Search terms by name |
Basic Usage
List all categories
wp term list category
List tags sorted by post count (desc)
wp term list post_tag --orderby=count --order=desc
Get category slugs for scripting
wp term list category --field=slug
Export categories as CSV
wp term list category --fields=term_id,name,slug,count --format=csv > categories.csv
Real-World Scenarios
Scenario 1: Find empty terms to clean up
wp term list category --hide_empty=false \
--fields=term_id,name,count \
--format=table | grep " 0 "
Scenario 2: List all WooCommerce product categories
wp term list product_cat \
--fields=term_id,name,slug,count \
--format=table
Scenario 3: Count terms per taxonomy
for tax in $(wp taxonomy list --field=name); do
COUNT=$(wp term list "$tax" --format=count 2>/dev/null || echo 0)
echo "$tax: $COUNT terms"
done
Quick Reference
wp term list <taxonomy> # All terms
wp term list category --orderby=count # By count
wp term list post_tag --field=slug # Slugs only
wp term list category --format=csv > cats.csv
Next Steps
wp term create— add new terms.wp term get— inspect a single term.wp post term— assign terms to posts.