Skip to main content

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

FlagDescription
--fields=FIELDSFields: term_id, name, slug, count, parent
--field=FIELDSingle field per line (for scripting)
--format=FORMATtable, json, csv, ids
--hide_emptyExclude terms with no posts (default: false)
--orderby=FIELDname, count, slug
--order=ASC_OR_DESCSort direction
--number=NMax number of terms
--search=TERMSearch 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