Skip to main content

Create Category

Creates a new category in WordPress with specified name, slug, description, and parent category.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Client Id - The client ID from the Connect node (optional if using direct credentials).
  • Category - An object containing the category properties such as name, slug, description, and parent.

Options

  • Site URL - (Optional) WordPress site URL. Use this if you want to authenticate directly without a Connect node.
  • Credentials - (Optional) WordPress username and application password. Use this if you want to authenticate directly without a Connect node.

Output

  • Category - The complete category object returned from WordPress, including the category ID, count, and all other category properties.

How It Works

The Create Category node creates a new WordPress category using the WordPress REST API.

When executed, the node:

  1. Retrieves the authentication (either from Client Id or direct credentials)
  2. Validates the category data
  3. Sends a POST request to /wp-json/wp/v2/categories endpoint
  4. Returns the created category object with all metadata

Category Object Properties

The Category input accepts an object with the following properties:

  • name - (Required) The category name. This is displayed to users.
  • slug - (Optional) URL-friendly version of the name. If not provided, WordPress will auto-generate from the name.
  • description - (Optional) Category description. Used by some themes and SEO plugins.
  • parent - (Optional) Parent category ID for creating hierarchical categories. Use 0 or omit for top-level categories.

Authentication Methods

Connect → Store Client Id → Create Category (use Client Id)

Method 2: Direct Credentials

Provide both Site URL and Credentials directly in the node options.

Requirements

  • A WordPress site with REST API enabled (WordPress 4.7+)
  • Appropriate user permissions (editor role or higher to manage categories)
  • Unique category name (WordPress won't create duplicate category names)

Error Handling

The node will return specific errors in the following cases:

  • Missing or empty Category data
  • Invalid category properties
  • Duplicate category name (category with same name already exists)
  • Invalid parent category ID
  • Authentication failure
  • Insufficient permissions to manage categories
  • Network connection errors
  • WordPress REST API disabled

Usage Notes

  • Category names must be unique - WordPress will return an error if a category with the same name exists
  • If slug is not provided, WordPress auto-generates it from the name
  • Slugs must be unique and URL-safe (lowercase, no spaces or special characters)
  • Parent category must exist before creating child categories
  • The count field in the result shows 0 for newly created categories
  • Categories are immediately available for use in posts

Example: Create Simple Category

Input - Category:

{
"name": "Technology",
"description": "Posts about technology and software"
}

Output - Category:

{
"id": 45,
"count": 0,
"description": "Posts about technology and software",
"link": "https://yoursite.com/category/technology/",
"name": "Technology",
"slug": "technology",
"parent": 0
}

Example: Create Category with Custom Slug

Input - Category:

{
"name": "Web Development",
"slug": "web-dev",
"description": "Articles about web development"
}

Example: Create Subcategory

To create a subcategory under an existing category:

Step 1: Get parent category ID Use List Categories or Get node to find the parent category ID (e.g., 45).

Step 2: Create subcategory

{
"name": "JavaScript",
"description": "JavaScript programming tutorials",
"parent": 45
}

This creates "JavaScript" as a child of "Technology" (ID: 45).

Example: Create Category Hierarchy

To create a multi-level category hierarchy:

1. Create "Programming" → Get ID (e.g., 10)
2. Create "Web Development" with parent: 10 → Get ID (e.g., 15)
3. Create "Frontend" with parent: 15
4. Create "Backend" with parent: 15

Result:

Programming (10)
└── Web Development (15)
├── Frontend
└── Backend

Common Use Cases

Content Organization

  • Set up category structure for new blogs
  • Organize existing content into categories
  • Create categories based on content analysis

Automated Taxonomy Management

  • Create categories from data sources (CSV, Excel)
  • Build category hierarchies programmatically
  • Sync categories across multiple WordPress sites

Dynamic Category Creation

  • Create categories based on post content
  • Generate categories from tags or custom taxonomies
  • Create categories from external data sources

Migration and Setup

  • Import category structure from another CMS
  • Replicate category hierarchy across environments
  • Bulk category creation for new sites

Best Practices

  • Use descriptive category names that users can understand
  • Create a logical hierarchy with parent/child relationships
  • Use slugs that are SEO-friendly and descriptive
  • Add descriptions for better SEO and user understanding
  • Plan your category structure before creating categories
  • Avoid creating too many top-level categories (5-10 is typical)
  • Use subcategories to organize within broader topics
  • Check if category exists before creating (use List Categories)
  • Handle duplicate name errors gracefully

SEO Considerations

  • Use keyword-rich category names
  • Write descriptive category descriptions (many themes show these)
  • Use clean, readable slugs
  • Organize content logically with hierarchies
  • Avoid keyword stuffing in category names
  • Create categories that match user search intent

Troubleshooting

Error: "Category cannot be empty"

  • Ensure you're passing a valid category object
  • At minimum, include a name property

Error: Duplicate category

  • A category with the same name already exists
  • Use List Categories to check existing categories
  • Either use the existing category or choose a different name

Error: "Invalid parent category ID"

  • The specified parent category doesn't exist
  • Verify the parent ID using List Categories or Get node
  • Ensure parent category is created before the child

Category created but not showing in WordPress:

  • Check the WordPress admin panel under Posts > Categories
  • Verify user permissions
  • Clear WordPress cache if using caching plugins

Working with Category IDs

After creating categories, you'll need their IDs to:

  • Assign categories to posts
  • Create subcategories
  • Update or delete categories

Example flow:

1. Create Category → Store category.id
2. Create Post with categories: [stored_id]

Category Hierarchy Best Practices

Good Hierarchy Example:

Technology
├── Web Development
│ ├── Frontend
│ └── Backend
└── Mobile Development
├── iOS
└── Android

Avoid Deep Nesting:

  • Limit to 2-3 levels deep
  • Too many levels confuse users and search engines
  • Broader categories are usually better

Managing Category Structure

Before Creating Categories:

  1. List existing categories to avoid duplicates
  2. Plan the hierarchy structure
  3. Identify parent category IDs if creating subcategories

After Creating Categories:

  1. Store the returned category ID for future use
  2. Verify the category appears in WordPress admin
  3. Test category assignment to posts

Performance Considerations

  • Creating categories is a lightweight operation
  • No significant performance impact
  • Categories are cached by WordPress
  • Bulk category creation should be throttled to avoid API rate limits

Automation Patterns

Create Categories from List

For each category_name in category_list:
- Check if category exists (List Categories + filter)
- If not exists: Create Category
- Store category ID

Mirror Category Structure

Source Site:
- List Categories → Get all categories
Target Site:
- For each category:
- Create Category with same properties
- Map old ID to new ID

Dynamic Category Assignment

- Analyze post content
- Extract topic/keywords
- Check if category exists for topic
- If not: Create Category
- Assign category to post