Auto-Categorize WordPress Posts with AI using n8n

This unique n8n workflow solves the tedious problem of manually categorizing WordPress blog posts by using AI-driven categorization. It automates assigning the most relevant category to each post, saving hours and eliminating costly errors in content organization.
wordpress
agent
lmChatOpenAi
+2
Workflow Identifier: 1696
NODES in Use: Manual Trigger, WordPress, Sticky Note, AI Agent, OpenAI Chat Model

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Sarah, a content manager responsible for over 80 blog posts on her company’s WordPress site. Every week, she spends hours manually reviewing each article title and assigning it to a relevant category so visitors can easily navigate the content. This process is slow, error-prone, and frustrating because categories sometimes get missed or wrongly assigned, leading to a poor user experience and lost traffic. Sarah knows that if only there was a way to automate this without complex coding, she’d save countless hours and improve accuracy.

This is precisely the problem solved by the “Auto categorize wordpress template” workflow in n8n. It uses AI to analyze blog post titles and automatically assign the best matching category from a predefined list within WordPress. The result: faster categorization, better content organization, and a happier Sarah.

2. What This Automation Does

When this workflow runs, it performs these key outcomes:

  • Retrieves all WordPress blog posts via the WordPress API.
  • Uses an AI Agent powered by OpenAI to examine each post title and select a single primary category ID from a fixed list of relevant categories.
  • Automatically updates each post in WordPress with its new AI-generated category, eliminating manual work.
  • Drastically reduces the time spent categorizing dozens of posts from hours to just a couple of minutes.
  • Ensures consistency by using a fixed category list, improving site navigation and SEO.
  • Runs via a simple manual trigger, allowing controlled batch processing.

This automation directly solves Sarah’s pain points, cutting down hours of manual sorting into a seamless and accurate process.

3. Prerequisites ⚙️

  • n8n Account with access to workflows and credential management. (Self-hosting option possible if preferred.)
  • WordPress API credentials linked to the site where posts reside.
  • OpenAI API credentials for AI-powered text analysis.
  • Basic knowledge of setting up n8n workflows and API credential configuration.

4. Step-by-Step Guide

Step 1: Create a Manual Trigger Node

Navigate to n8n’s editor, click “+” → “Manual Trigger” to add a node that will start the workflow on command. This lets you test and run the automation whenever you want.

You should see a node box labeled “When clicking ‘Test workflow’”, indicating it awaits manual execution.

Tip: Avoid running this on live posts without testing first.

Step 2: Add WordPress “Get All Posts” Node

Click “+” → “WordPress” → Choose “getAll” operation. Connect this node’s input to the Manual Trigger node’s output.

Configure credentials linked to your WordPress site. Set Return All to true to fetch every blog post available.

The output will be the list of all posts with details including their titles and IDs.

Note: Turn off return all if you encounter issues to limit fetched posts.

Step 3: Integrate AI Agent Node for Categorization

Add a new AI Agent node from LangChain. This node uses AI to assign categories based on blog post titles.

Set up the prompt text exactly as:

=You are an expert content strategist and taxonomy specialist with extensive experience in blog categorization and content organization.

I will provide you with a blog post's title. Your task is to assign ONE primary category ID from this fixed list:

13 = Content Creation
14 = Digital Marketing
15 = AI Tools
17 = Automation & Integration
18 = Productivity Tools
19 = Analytics & Strategy

Analyze the title and return only the single most relevant category ID number that best represents the main focus of the post. While a post might touch on multiple topics, select the dominant theme that would be most useful for navigation purposes.

{{ $json.title.rendered }}

Output only the category number

Connect the output of the WordPress getAll node to the AI Agent input.

This sets the stage for the AI to evaluate each post title and decide its category.

Step 4: Insert OpenAI Chat Model Node (Optional but Recommended)

Add the LangChain OpenAI Chat Model node before the AI Agent node if you want to leverage advanced AI language models. Connect the output of this node to the AI Agent’s input.

Configure your OpenAI API credentials here. This node acts as the AI processor that the Agent uses behind the scenes.

Step 5: Update WordPress Posts with Categories

Add another WordPress node but set the operation to update. Connect this node to the AI Agent node’s output.

Under updateFields, specify categories to dynamically set the category ID to the AI agent’s output value.

Configure credentials again for authentication.

Proper mapping between postId (from the original WordPress posts) and category output is critical for successful updates.

Step 6: Connect the Workflow

Ensure the workflow connections flow in this order: Manual Trigger → WordPress Get All Posts → OpenAI Chat Model (optional) → AI Agent → WordPress Update Post.

Step 7: Test the Workflow

Click the “Test Workflow” button. The system fetches posts, categorizes them with AI, and updates them in WordPress.

Check your WordPress admin panel to verify the categories were correctly assigned.

Common Mistake: Incorrect category IDs or WordPress credentials will cause errors in updating posts.

Step 8: Review and Optimize

Adjust the prompt in the AI Agent node if you want to refine category selection criteria or expand categories.

5. Customizations ✏️

  • Change Category List in AI Agent Prompt: Edit the prompt text to add or modify category IDs for your WordPress taxonomy.
  • Limit Posts Processed: In the WordPress Get All Posts node, turn off Return All and add filters if you want to batch categorize new posts only.
  • Add Notifications: Add an Email or Slack node after the update node to send alerts when categories are updated.

6. Troubleshooting 🔧

  • Problem: “Failed to authenticate WordPress API”
    Cause: Incorrect API keys or permissions.
    Solution: Verify API credential validity and permissions in WordPress dashboard under Users > Applications Passwords.
  • Problem: “Category update not reflected in WordPress”
    Cause: Data mapping errors or API update failure.
    Solution: Double-check that the post ID and category fields are correctly mapped in the update WordPress node.

7. Pre-Production Checklist ✅

  • Verify WordPress API credentials and permissions allow read & write access.
  • Test the AI Agent prompt with a few sample titles to ensure correct category ID returns.
  • Backup WordPress database before running full batch updates as a rollback safety.
  • Confirm no conflicting plugins interfere with API updates.

8. Deployment Guide

Activate the workflow in n8n’s editor by toggling it to Active. Run manual triggers as needed or schedule triggers for batch processing.

Monitor execution in n8n’s dashboard for errors or failures. Logs help detect any hiccups during post updates.

9. FAQs

  • Can I use another AI provider besides OpenAI?
    Yes, but you need to configure their API in the AI Agent accordingly.
  • Does this consume a lot of OpenAI credits?
    The cost depends on the number of posts processed and AI model used. Optimize by batch processing.
  • Is my WordPress data safe?
    Yes, all data flows securely using authenticated API calls.

10. Conclusion

By following this guide, you’ve built a powerful n8n workflow that automatically assigns the perfect category to every WordPress blog post. This saves hours of manual labor, reduces human error, and improves your site’s organization and navigation.

Next, consider extending this automation by integrating notifications, expanding categories dynamically, or automating metadata tagging. You now hold the key to smarter WordPress content management with AI and n8n!

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free