wp term create
Overview
Add new terms to any WordPress taxonomy — categories, tags, or custom taxonomies like product categories. Supports slug, description, and parent assignment.
What It Does
wp term create calls wp_insert_term() to create a new taxonomy term. Returns the new term ID on success.
Syntax
wp term create <taxonomy> <term> [OPTIONS]
Arguments & Options
| Flag | Description |
|---|---|
--slug=SLUG | URL-friendly slug (auto-generated from name if omitted) |
--description=TEXT | Term description |
--parent=TERM_ID | Parent term ID (for hierarchical taxonomies) |
--porcelain | Output the new term ID only |
Basic Usage
Create a category
wp term create category "Technology"
Create with custom slug and description
wp term create category "Machine Learning" \
--slug=machine-learning \
--description="Articles about AI and ML"
Create a child category
PARENT_ID=$(wp term get category python --field=term_id)
wp term create category "Django" --parent=$PARENT_ID
Create a WooCommerce product category
wp term create product_cat "Electronics" --slug=electronics
Real-World Scenarios
Scenario 1: Set up a full category hierarchy
DEV_ID=$(wp term create category "Development" --slug=development --porcelain)
wp term create category "Frontend" --slug=frontend --parent=$DEV_ID
wp term create category "Backend" --slug=backend --parent=$DEV_ID
wp term create category "DevOps" --slug=devops --parent=$DEV_ID
Scenario 2: Bulk create tags from a list
TAGS="wordpress wpcli automation devops sysadmin"
for tag in $TAGS; do
wp term create post_tag "$tag" --slug="$tag"
done
Quick Reference
wp term create <taxonomy> "<Name>" # Basic create
wp term create <taxonomy> "<Name>" --slug=slug # Custom slug
wp term create <taxonomy> "<Name>" --parent=<id>
TERM_ID=$(wp term create <taxonomy> "<Name>" --porcelain)
Next Steps
wp term update— modify a term after creation.wp post term— assign the new term to posts.wp term list— verify creation.