# Apify Wordpress Publisher (`brasil-api-lcm/apify-wordpress-publisher`) Actor

Publish and sync Apify Dataset items or JSON payloads directly to WordPress Posts, Pages, or Custom Post Types via REST API. Supports dot-notation mapping, featured image upload, slug upsert, and dry-run mode.

- **URL**: https://apify.com/brasil-api-lcm/apify-wordpress-publisher.md
- **Developed by:** [Lucas Maia](https://apify.com/brasil-api-lcm) (community)
- **Categories:** Automation, Integrations, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 wordpress post publisheds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## WordPress Dataset Publisher & Sync (Apify to WP)

Publish and synchronize any **Apify Dataset** (or direct JSON payload from **n8n**, **Make**, or **AI Agents via MCP**) directly into **WordPress** Posts, Pages, or Custom Post Types via the official WordPress REST API.

Built to fulfill the Apify community request: [WordPress Integration](https://apify.com/ideas/wordpress-integration).

### Features

- **Any Scraper → WordPress:** Pass an Apify `datasetId` from Google Maps, News, E-commerce, or Jobs scrapers, or pass raw JSON `items`.
- **Flexible Field Mapping (Dot Notation):** Map nested fields (e.g., `metadata.headline`, `author.name`) to WordPress `title`, `content`, `excerpt`, `slug`, `categories`, `tags`, and `featuredImageUrl`.
- **Idempotent Upsert by Slug:** Automatically updates existing posts with matching slugs instead of creating duplicates.
- **Featured Image Upload:** Downloads remote image URLs and uploads them to `/wp-json/wp/v2/media`, attaching `featured_media`.
- **Safe Dry-Run Mode:** Test authentication and field mapping before writing a single post.

### WordPress Setup (2 Minutes)

1. In your WordPress Admin, go to **Users → Profile**.
2. Scroll down to **Application Passwords**, enter a name (e.g., `Apify Publisher`), and click **Add New Application Password**.
3. Copy the generated password and paste it into `wpAppPassword` (stored securely as a secret input).

### Example Input

```json
{
  "wpSiteUrl": "https://example.com",
  "wpUsername": "editor",
  "wpAppPassword": "xxxx xxxx xxxx xxxx xxxx xxxx",
  "postType": "posts",
  "defaultStatus": "draft",
  "upsertBySlug": true,
  "uploadFeaturedImage": true,
  "items": [
    {
      "title": "Sample Automated Report",
      "content": "<p>Published directly from Apify.</p>",
      "excerpt": "Short summary.",
      "categories": ["Automation", "Data"],
      "image": "https://example.com/cover.jpg"
    }
  ]
}
```

# Actor input Schema

## `wpSiteUrl` (type: `string`):

Base URL of your WordPress site (e.g. https://example.com).

## `wpUsername` (type: `string`):

WordPress username that owns the Application Password.

## `wpAppPassword` (type: `string`):

Generated in WordPress Admin -> Users -> Profile -> Application Passwords.

## `datasetId` (type: `string`):

ID of an Apify Dataset from any scraper run. If omitted, provide direct items below.

## `items` (type: `array`):

Array of JSON objects to publish directly (ideal for n8n, Make, or MCP agent calls).

## `postType` (type: `string`):

REST base slug (e.g. posts, pages, or a custom post type registered with show_in_rest).

## `defaultStatus` (type: `string`):

WordPress status for newly created posts.

## `fieldMapping` (type: `object`):

Maps WordPress fields to keys in your source dataset items.

## `upsertBySlug` (type: `boolean`):

If enabled and a post with the same slug already exists, updates it instead of creating a duplicate.

## `uploadFeaturedImage` (type: `boolean`):

Downloads the mapped featuredImageUrl and attaches it as featured_media.

## `maxItems` (type: `integer`):

Safety cap on how many items to publish per run.

## `dryRun` (type: `boolean`):

Validates WordPress authentication and field mapping without creating or modifying posts.

## Actor input object example

```json
{
  "wpSiteUrl": "https://example.com",
  "items": [],
  "postType": "posts",
  "defaultStatus": "draft",
  "fieldMapping": {
    "title": "title",
    "content": "content",
    "excerpt": "excerpt",
    "slug": "slug",
    "featuredImageUrl": "image",
    "categories": "categories",
    "tags": "tags"
  },
  "upsertBySlug": true,
  "uploadFeaturedImage": true,
  "maxItems": 50,
  "dryRun": false
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "wpSiteUrl": "https://example.com"
};

// Run the Actor and wait for it to finish
const run = await client.actor("brasil-api-lcm/apify-wordpress-publisher").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "wpSiteUrl": "https://example.com" }

# Run the Actor and wait for it to finish
run = client.actor("brasil-api-lcm/apify-wordpress-publisher").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "wpSiteUrl": "https://example.com"
}' |
apify call brasil-api-lcm/apify-wordpress-publisher --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,brasil-api-lcm/apify-wordpress-publisher"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/XxuYFHtglV4hPUGsU/builds/F6D9ol5P0R3aEndMK/openapi.json
