Skip to content

WordPress

With WordPress as your content source, EdgeKit keeps a read-only copy of your posts and their authors in your organization’s own database. Content › Content › Items and Content › Content › Authors show it. WordPress stays the system of record: EdgeKit only reads from WordPress over its REST API, and never writes to it.

Do these in order:

  1. A WordPress user for EdgeKit. Create a dedicated user with the Editor role, and create an Application Password for it. EdgeKit reads WordPress with them. You enter both in step 2, on the source’s page; the password is never shown again. This user can read every draft on your site.

    WordPress offers Application Passwords only on a site served over HTTPS. A security plugin can switch them off; Wordfence does by default. Basic authentication set on the web server in front of WordPress breaks them.

  2. The content source. Add a WordPress source in Content › Configuration › Sources, then open it and save the username and Application Password under CMS credential. EdgeKit checks them against your site first and refuses a pair WordPress rejects. Saving them redeploys your organization’s API. The source’s fields:

    • API base URL: your site’s REST root, https://<host>/wp-json. It must be an https URL. EdgeKit sends the WordPress credential to this host.
    • Site: the EdgeKit site every item from this WordPress appears on.
    • Post types: the WordPress post types to sync, separated by commas, such as post, page. It starts as post and needs at least one. Every listed post type must stay available in the REST API: when one is not, because its plugin is off or it is not shown in REST, the first sync and nightly reconciliation stop with an error instead of leaving that type out, and nothing is marked deleted. Remove a post type from the list before you remove it from WordPress.
    • Default language: used for a post that carries no language.

    Saving starts the first sync. See Connect a content source.

  3. An API key. Issue a tenant API key pinned to any of your sites. See Issue and revoke API keys.

  4. A webhook. Make your WordPress call the sync route with that key whenever a post is saved, trashed or deleted. EdgeKit ships no WordPress plugin: use a webhook plugin of your choice, or your own code. Whatever you use must be able to:

    • send on a post’s save and on its delete;
    • set an Authorization: Bearer <key> header;
    • send the JSON body below, with the source’s Source key as source and the post’s id as a string.
Terminal window
curl -i https://<tenant>.edgekit.ai/v1/content/sync \
-H 'Authorization: Bearer ek_your_key' \
-H 'Content-Type: application/json' \
-d '{"source": "wordpress", "events": [{"id": "1234", "type": "post"}]}'
const postId = 1234; // the WordPress post id
await fetch('https://<tenant>.edgekit.ai/v1/content/sync', {
method: 'POST',
headers: {
authorization: `Bearer ${process.env.EDGEKIT_API_KEY}`,
'content-type': 'application/json',
},
body: JSON.stringify({
source: 'wordpress', // your WordPress source's source key
events: [{ id: String(postId), type: 'post' }],
}),
});

To refresh an author’s profile, send the WordPress user’s id with "type": "author" when the profile changes. The request and its answers are in Keep content in sync.

An event tells EdgeKit which post or author changed. EdgeKit then reads its current state from WordPress and writes that, so events that arrive twice or out of order change nothing extra. Repeats of one id within 5 seconds are read once.

The type you send for a post is not trusted. WordPress answers the same for an id it does not have and for an id of another post type, so a wrong type would delete a live item. EdgeKit ignores it: it looks the id up under each of your Post types in order, takes the first that has it, and marks the item deleted only when none does. With several post types listed, one event can cost one read per type.

A post takes one read, which carries its author, featured image and terms. Its categories take one more when it has any, and its Co-Authors Plus bylines one more when it has any. A post type other than post or page adds one read to find its REST route. An author takes one read of the WordPress user. A lookup in

Content › Content › Sync makes the same reads.

EdgeKit reads each post as an editor sees it. An answer without the editor’s fields, such as an anonymous copy served by a cache in front of your site, is an error and is not stored. An answer that says the REST route itself is missing, such as from a wrong API base URL, is an error too, and deletes nothing.

In WordPress In EdgeKit
The post’s id CMS id
The post type Type, verbatim
lang, when a multilingual plugin exposes it Language, in canonical form, else the Default language
The title, and the excerpt as written in the editor Headline, Description
The featured image Lead image: URL, alt text, caption, width and height
Co-Authors Plus bylines, else the post’s author Authors
Categories Sections, each with its parent. No primary section
Tags Tags
The rendered content Body
The post’s date, and its modified date Display date, Updated in CMS
The post’s permalink The item’s URL on the Site
The WordPress user The author’s name, slug, profile URL, avatar and bio

In the body, paragraphs, headings, lists, block quotes and images become structured blocks, with bold, italic, underline, strikethrough, code, superscript, subscript and links kept. Any other element, such as an embed, a table, a gallery or a pull quote, is kept as WordPress rendered it and has no text in EdgeKit, so search does not find it.

  • The body is what your site renders. EdgeKit stores the content after your site’s the_content filters have run. A plugin that cuts, replaces or adds to a post’s content there changes EdgeKit’s copy the same way.
  • Language. Polylang Pro exposes lang in the REST API. Without it, every post gets the Default language. Each translation is its own post in WordPress, so it is its own item in EdgeKit.
  • Authors. A post with Co-Authors Plus bylines credits all of them, in their order. Any other post credits its WordPress author. A Co-Authors Plus byline is refreshed when a post crediting it syncs; an author event re-reads a WordPress user only. If you install Co-Authors Plus after the first sync, each person gets a second author in EdgeKit, under a new id.
  • No first-published date. WordPress keeps one publish date, which can be edited, so First published stays empty.
  • Not mapped. Custom taxonomies, ACF fields and post meta stay only in the stored WordPress response.
In WordPress Status
publish published
future scheduled
draft, pending, private draft
trash, or no listed post type has the id deleted

A scheduled item carries the post’s date as its scheduled time. A private post is draft, so it is never searchable.

Saving the content source starts it. EdgeKit lists the ids of each listed post type, 100 at a time, then reads each post as an event would.

  • Every status. Drafts, pending, private and scheduled posts are synced along with published ones. A trashed post is read too, and stores nothing.
  • Rate. EdgeKit reads at most 4 posts every 3 seconds: about 21 hours per 100,000 posts.

The first sync starts when the source is saved, before the credential is in place, so it fails on its first page and waits. Once the credential is saved and deployed, select Start full sync on the source’s page. The same button resumes a full sync that was interrupted.

A webhook with Flowsystems Webhook Actions

Section titled “A webhook with Flowsystems Webhook Actions”

Any plugin works that can send the request in step 4 when a post is saved and when it is deleted. This one does it with an import file and a few lines of PHP for the source key, at version 3.4.3.

  1. Install and activate Flowsystems Webhook Actions from the WordPress plugin directory.
  2. Save the JSON below as a file. Replace <tenant> with your organization’s API host.
  3. In the plugin, import the file. It asks which credential the webhook uses: create one of type Bearer and paste the tenant API key from step 3 above.
{
"fswa_export": { "version": 1, "kind": "webhook" },
"credentials": [
{
"ref": "edgekit-api-key",
"name": "EdgeKit tenant API key",
"type": "bearer"
}
],
"webhooks": [
{
"uuid": "0d0f5e0a-6c1b-4d0e-9a57-ed9e4b175ec1",
"name": "EdgeKit content sync",
"endpoint_url": "https://<tenant>.edgekit.ai/v1/content/sync?source=wordpress",
"http_method": "POST",
"is_enabled": true,
"is_synchronous": false,
"auth": { "mode": "vault", "credential_ref": "edgekit-api-key" },
"triggers": [
{
"name": "wp_insert_post",
"schema": {
"field_mapping": {
"mappings": [
{
"source": "args.0",
"target": "events.0.id",
"cast": "string"
},
{ "source": "args.1.post_type", "target": "events.0.type" }
],
"excluded": [],
"includeUnmapped": false
},
"conditions": {
"enabled": true,
"type": "and",
"rules": [
{
"field": "args.1.post_type",
"operator": "equals",
"value": "post"
},
{
"field": "args.1.post_status",
"operator": "not_equals",
"value": "auto-draft"
}
]
},
"conditions_evaluate_on": "original"
}
},
{
"name": "deleted_post",
"schema": {
"field_mapping": {
"mappings": [
{
"source": "args.0",
"target": "events.0.id",
"cast": "string"
},
{ "source": "args.1.post_type", "target": "events.0.type" }
],
"excluded": [],
"includeUnmapped": false
},
"conditions": {
"enabled": true,
"type": "and",
"rules": [
{
"field": "args.1.post_type",
"operator": "equals",
"value": "post"
}
]
},
"conditions_evaluate_on": "original"
}
}
]
}
]
}
  1. Set the source key in the webhook’s URL: replace wordpress in ?source=wordpress with your source’s Source key. The plugin’s field mapping copies values from the WordPress event and cannot add a fixed one, so the URL carries it.

What it does:

  • Two triggers. wp_insert_post fires on every save, trash, restore and scheduled go-live; deleted_post fires on a permanent delete.
  • The body is {"events":[{"id":"<post id>","type":"<post type>"}]}: the mapping builds events, with the id cast to a string. The source key rides the URL’s source parameter.
  • Conditions send only the post type and skip auto-drafts, so revisions and autosaves send nothing. To sync another post type, change post in both triggers, or add a second webhook for it.
  • Delivery is queued and sent by WP-Cron within about a minute. A failed delivery is retried; a 401 or 422 from EdgeKit is not, since a retry cannot fix it.

Two limits of this setup:

  • WP-Cron must run. On a site that has turned it off and has no system cron calling it, nothing is sent.
  • A change to tags, categories or post meta alone, made outside the editor, fires neither trigger.

EdgeKit hears of a change only when your WordPress sends the post’s id. EdgeKit does not retry a webhook it never received, and your webhook setup decides which changes send one. Three kinds are easy to miss:

  • A scheduled post going live. WordPress publishes it without a save in the editor, and its modified date does not move. The item stays scheduled until its id is sent.
  • A change to tags, categories or post meta alone, made outside the editor. The post’s modified date does not move.
  • A webhook that failed. The item stays as it was until the post’s next event.

Send the id again, or look it up in Content › Content › Sync and select Re-sync, to correct one item.

Nightly reconciliation is off unless EdgeKit turns it on for you. For WordPress, ask for it. Each night it re-reads the posts modified since the last run, marks deleted the published items WordPress no longer has, and re-reads every draft and scheduled item, which takes a scheduled post live when its webhook was missed. See Nightly reconciliation.

  • Multisite networks are not supported. A source reads one site’s REST root, and every item lands on one EdgeKit site.
  • WordPress.com-hosted sites are untested.
  • One WordPress site per source. To connect another WordPress installation, add it as a new source with its own source key, credential and webhook.
  • No writes through the content API. A wordpress source answers 409 there. To keep your own mapping and push it from WordPress yourself, use a Custom CMS source instead; see Push content from your CMS.

edgekit.ai