AI-Powered WordPress Post Categorization - n8n Workflow

Automate WordPress content taxonomy using an AI expert agent. This powerful n8n workflow retrieves all posts, categorizes them using OpenAI, and updates categories instantly, utilizing crucial n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Markdown-formatted text:

Content Managers and Blog Administrators overwhelmed by manually sorting large archives.
Developers looking for advanced examples of using the OpenAI LangChain n8n node for data processing.
Users seeking efficient n8n templates for CMS automation and AI integration.
Agencies needing to quickly restructure client content taxonomy without writing custom code.

Overview

Managing content taxonomy can be time-consuming, especially when dealing with hundreds of legacy posts. This automation solves the manual categorization problem by leveraging the intelligence of a large language model (LLM) powered by an n8n workflow.

This specific n8n workflow acts as an expert content strategist, analyzing the title of every retrieved WordPress post and assigning the most appropriate category ID from a predefined list. This makes content organization instantaneous and scalable. By using this n8n template, users can save dozens of hours on manual administrative tasks, ensuring a clean and consistent content structure across their entire WordPress site. The use of the LangChain AI Agent within this n8n node architecture provides sophisticated classification capabilities.

How it Works

Markdown-formatted text:


  1. Trigger Execution: The process begins with the 'When clicking ‘Test workflow’' n8n trigger. While manual, this trigger allows for simple batch execution. For production environments, you might swap this for a Cron n8n trigger to run daily checks.

  2. Retrieve Posts: The 'Get All Wordpress Posts' n8n node connects to WordPress and retrieves all existing posts in preparation for processing. Note that the 'Return All' option is enabled for bulk operation.

  3. Define AI Model: The 'OpenAI Chat Model' n8n node sets up the necessary credentials and configuration for the language model, which is used by the subsequent agent.

  4. AI Categorization: The powerful 'AI Agent' n8n node receives the list of posts. It utilizes a finely tuned system prompt defining it as a 'taxonomy specialist.' For each post, the agent analyzes the title.rendered and is instructed to output only the single most relevant category ID number from a fixed list defined within the prompt (e.g., 13, 14, 15, etc.).

  5. Update WordPress: Finally, the last 'Wordpress' n8n node performs an 'Update' operation. It uses an expression to dynamically reference the post ID being processed and injects the categorized ID output ({{ $json.output }}) directly into the categories field, completing the automatic update for every post processed by the n8n workflow.

Installation Guide

Markdown-formatted text:


  1. Import: Copy the provided n8n workflow JSON code and import it into your n8n instance using the 'New' -> 'Import from JSON' function.

  2. WordPress Credentials: Locate both 'Wordpress' n8n node configurations. You will need to create or select existing WordPress API credentials (API Key and Host URL, usually via Application Passwords). This is crucial for both reading and writing post data.

  3. OpenAI Credentials: Select or create your OpenAI API Key credentials in the 'OpenAI Chat Model' n8n node. This allows the AI agent to access the LLM service.

  4. Customize Taxonomy: IMPORTANT: Go to the 'AI Agent' n8n node and carefully review the prompt. You must edit the fixed list of category IDs and their corresponding names to match the categories you have already defined within your WordPress site.

  5. Testing: Execute the n8n workflow by clicking the 'Test workflow' n8n trigger to ensure the categorization logic runs correctly on a small subset of posts before running the full batch.

Node Details

Markdown-formatted text:

When clicking ‘Test workflow’ (n8n trigger):
Function: Manually initiates the entire n8n workflow. Ideal for batch processing tasks.
Key Configuration: Simple manual trigger.
Get All Wordpress Posts (Wordpress n8n node):
Function: Retrieves the entire inventory of WordPress blog posts that need categorization.
Key Configuration: Operation set to getAll; Return All is set to true to process all items in a single run.
OpenAI Chat Model (LangChain n8n node):
Function: Provides the necessary bridge to the OpenAI LLM service, establishing the AI engine for the LangChain agent.
Key Configuration: Requires valid OpenAI API credentials.
AI Agent (LangChain n8n node):
Function: Executes the core categorization logic. It uses a detailed prompt to analyze the post title and outputs only a single category ID number.
Key Configuration: Prompt Type is define. Prompt strictly dictates category ID output based on the input post title ({{ $json.title.rendered }}). Users must update the fixed ID list in this n8n node.
Wordpress (Wordpress n8n node):
Function: Updates the processed post with the newly generated category ID.
* Key Configuration: Operation set to update; Post ID dynamically linked to the original item ID; categories parameter dynamically set using the AI output (={{ $json.output }}).

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by

I create automations with A.I. for SEO content and other smart automations.

Featured*