This blog has more than 800 articles, a custom theme and one person behind it. Keeping it healthy by hand would be a full-time job: checking that pages load, reading Search Console, deleting spam, updating old posts. Instead, four agents built with WordPress automation with n8n do the routine work, and I approve the decisions that matter. This article explains the whole setup, with the patterns you can reuse for your own site or product.

The setup at a glance

Agent When What it does on its own What it asks me first
Health monitor Every 15 minutes + 07:00 daily Checks key pages, ads.txt, sitemap and feed; a daily report with PageSpeed, updates, SSL, disk, PHP errors Nothing: it only reports
Search performance Mondays Finds posts Google shows often but people rarely click, drafts better titles and descriptions Every change
Comments Daily Moves spam to the Spam folder, drafts replies to real readers Every reply
Content updater Wednesdays Picks posts close to the top of Google or losing traffic and drafts improved versions Every update

The stack: WordPress with a custom PHP theme, n8n self-hosted, Google Search Console and PageSpeed Insights APIs, Claude Haiku through OpenRouter for the language tasks, and plain SMTP for email.

The design rule: agents propose, people approve

Automating everything is easy; trusting it is not. I split each job into two kinds of action:

That rule decides the architecture: the theme stores proposals and exposes review pages, and n8n does the thinking and scheduling.

WordPress automation with n8n: architecture of the four AI agents, the WordPress review pages and the approval loop
How the four agents fit together: n8n does the checking and drafting, WordPress refuses bad proposals in code, and nothing visible goes live without approval.

WordPress automation with n8n: how the agents reach WordPress

Each agent uses a small set of custom REST endpoints in the theme, under /wp-json/ajmani/v1/, protected so only an administrator account can call them. n8n authenticates with a WordPress application password, which can be revoked without touching the main login.

register_rest_route( 'ajmani/v1', '/health', array(
    'methods'             => 'GET',
    'callback'            => 'ajmani_ma_health_report',
    'permission_callback' => function () {
        return current_user_can( 'manage_options' );   // administrators only
    },
) );

A practical detail that cost me a debugging session: when a WordPress endpoint returns a JSON list, n8n splits it into separate items, and an empty list produces no items at all, which silently stops the workflow. The endpoints return objects instead ({"posts": [...]}), so an empty result is still one item the next node can handle.

Agent 1: the health monitor

Every 15 minutes it fetches the homepage, an article, the About page, ads.txt, the sitemap and the RSS feed. A page counts as broken if it does not answer, returns an error, shows WordPress’s “critical error” page, or loads without a piece of text that a healthy page always contains. That last check catches the silent failures a status code misses.

To avoid an email every 15 minutes during an outage, the workflow remembers the previous state in n8n’s workflow storage and only sends a message when something goes down or comes back.

Every morning it also reads a private health endpoint in the theme and sends one report: pending plugin and core updates, comments waiting, days since the last post, SEO gaps, SSL days left (read from the live certificate), disk usage, overdue scheduled tasks, PHP fatal errors from the log, plus PageSpeed scores for the homepage and the latest article and a check of 15 random articles.

Agent 2: search performance

Every Monday it compares each post’s click-through rate in Search Console with what its average position normally gets. A page at position 6 with a 0.3% click rate is losing clicks it already earned, usually because the title does not match what people searched for. For the posts losing the most clicks, the agent sends Claude the article, its section headings, the actual search queries and the current title, and asks for a better title and description.

Every proposal goes through checks in code before it is saved: length limits, and the post’s SEO focus keyword must appear in both the title and the description. Proposals that fail are dropped and listed in the email. Approved changes are measured again 28 days later, so the review page shows click-through rate before and after each change.

Agent 3: comments

Spam is handled in two layers. The cheap layer runs in the theme when the comment is submitted: a hidden honeypot field and a minimum fill-in time stop most bots, and rules move obvious spam (URL shorteners, several links, adult or casino phrases, random-letter names, links whose visible text hides their destination) straight to the Spam folder. On its first run this cleared a backlog of 133 waiting comments down to 2.

Whatever the rules let through goes to the daily agent, which classifies each comment as spam, genuine or unsure. One lesson from building it: I first sent the model the comment text with the HTML removed, and it called a spam comment “genuine” because the link to an unrelated site was hidden behind the words “git-native”. Now the model also receives the real destination of every link, and a rule catches disguised links before the model is even asked.

For genuine comments the agent drafts a short reply in my voice. Replies wait in a review page; nothing is posted automatically, and a draft that contains a link is never offered.

Agent 4: the content updater

Every Wednesday it picks up to three posts, rotating between four kinds of opportunity:

For each one, the model receives the full article and the real search queries, with strict rules: keep every heading and link, never invent version numbers, prices or statistics, answer the main question early, and for “X vs Y” searches add a comparison table and a verdict. WordPress then refuses any draft that is shorter than the original, drops an internal link, loses the focus keyword or loses sections. The review page shows a preview and a text diff; approving saves a normal WordPress revision.

The parts that are not AI

Several of the biggest improvements were plain engineering in the theme, and they made the agents more effective:

What I would reuse on any site

Want this for your site?

The same agents work for any WordPress site, online shop or content-heavy business: uptime and health reports, Search Console-driven improvements, comment and form spam handling, and content refreshes that someone approves. I can set them up on your own n8n (or host one for you), adapt them to your tools and train your team on the review pages.

Official resources for WordPress automation with n8n

Documentation and references for WordPress automation with n8n: