WordPress Auto-Poster: Automating Content Creation with Node.js
One recurring challenge in content-heavy WordPress sites is the overhead of populating them with structured, realistic content — whether for staging environments, demos, or testing editorial workflows. I built content-creator to solve this with a single Node.js script that handles the entire pipeline: from generating text and fetching images to publishing posts or pages directly via the WordPress REST API.
What it does
The tool runs in batch mode from the command line. You tell it how many items to create, what status to assign them, and whether you want posts or pages. It takes care of everything else — including making sure the target category exists before writing a single post.
auto-posted-content category exists in WordPress; creates it automatically if not. Runs once per batch.marked (GFM enabled) before being sent to WordPress.CLI interface
The script is designed to be run directly from the terminal with sensible defaults — one draft post if you call it with no arguments — and a full set of flags for when you need more control:
# Default: 1 draft post node index.js # 5 draft posts node index.js --count 5 # 3 published posts node index.js --count 3 --status publish # 2 draft pages with a page template node index.js -y pages -c 2 -t full-width.php # Show all options node index.js --help
The --status flag accepts any WordPress post status: draft, publish, pending, private, or future. The --template flag is only included in the API request when explicitly supplied — it's omitted entirely otherwise, rather than sending an empty value.
WordPress REST API surface
The tool touches five WordPress endpoints. All requests use HTTP Basic Auth with an Application Password — the safer option compared to a login password since it can be revoked independently from WordPress admin:
| Action | Method | Endpoint |
|---|---|---|
| Look up category | GET | /wp-json/wp/v2/categories?slug=… |
| Create category | POST | /wp-json/wp/v2/categories |
| Upload image | POST | /wp-json/wp/v2/media |
| Create post | POST | /wp-json/wp/v2/posts |
| Create page | POST | /wp-json/wp/v2/pages |
Project structure
The code is split into three focused modules, each with a single responsibility:
content-creator/ ├── index.js # CLI parsing, orchestrates the full flow ├── contentService.js # Fetches markdown content, image, converts to HTML ├── wordpressService.js # WordPress REST API calls ├── .env.example # Environment variable template └── package.json
Configuration is handled through a .env file with three variables: the WordPress base URL, a username, and an Application Password. Copy .env.example, fill in your credentials, and the tool is ready to run.
Why I built it this way
A tool that solves one problem cleanly is worth more than a framework that solves ten problems awkwardly.
The scope is intentionally narrow. This isn't a CMS replacement or a full content pipeline — it's a focused utility for a specific task: populating a WordPress instance with structured content quickly and repeatably. The three-module structure keeps concerns separated without over-engineering something that's meant to be transparent and easy to modify.
If you work with WordPress and find yourself manually populating test environments or staging sites, content-creator is worth a look. The setup takes about two minutes.