WP Content Sync
| AI Plugin Information | |
|---|---|
| Version | 3 |
| Download | Download Plugin |
# WP Content Sync – CLI Utility for AI Agents
A WordPress plugin that provides a WP-CLI interface for syncing WordPress content to/from the local filesystem, optimized for AI agent workflows.
## Installation
1. Activate the plugin in WordPress
2. Ensure WP-CLI is installed and available
## Commands
### Pull Command
Fetches posts from WordPress and exports them to the current working directory.
“`bash
wp content-sync pull [options]
“`
#### Options
– `–post_type=
– `–post_status=
– `–posts_per_page=
– `–post__in=
– `–category=
– `–author=
– `–s=
– `–date_query=
#### Examples
“`bash
# Pull all posts
wp content-sync pull
# Pull all pages
wp content-sync pull –post_type=page
# Pull specific posts by ID
wp content-sync pull –post__in=1,2,3,42
# Pull published posts from a specific category
wp content-sync pull –category=news –post_status=publish
# Pull posts by author
wp content-sync pull –author=5
# Search for posts
wp content-sync pull –s=”wordpress tutorial”
“`
#### Output Structure
The pull command creates the following files in your current working directory:
1. **[post_id].md** – Raw post content (one file per post)
– Example: `1042.md`
– Contains raw `post_content` without any HTML-to-Markdown conversion
2. **[post_id].featuredimage.[ext]** – Featured image (if exists)
– Example: `1042.featuredimage.jpg`
– Full-size original image
3. **manifest.json** – Complete metadata for all posts
– Contains all post fields (ID, title, status, dates, etc.)
– Includes all postmeta (including hidden keys)
– Includes taxonomy term assignments
– References featured image filename
### Push Command
Syncs local changes back to WordPress database.
“`bash
wp content-sync push
“`
#### How It Works
1. Reads `manifest.json` from current directory
2. Updates post content from `[post_id].md` files
3. Updates post metadata from manifest
4. Syncs featured images (uploads new/changed images)
5. Updates taxonomy term assignments
#### Example
“`bash
# After editing local files, push changes back
wp content-sync push
“`
## Workflow Example
“`bash
# Navigate to your working directory
cd ~/wordpress-content
# Pull all published posts
wp content-sync pull –post_status=publish
# Edit the markdown files and manifest.json as needed
# … make your changes …
# Push changes back to WordPress
wp content-sync push
“`
## Manifest.json Structure
“`json
[
{
“ID”: 1042,
“post_author”: “1”,
“post_date”: “2024-01-15 10:30:00”,
“post_date_gmt”: “2024-01-15 10:30:00”,
“post_title”: “Example Post Title”,
“post_excerpt”: “Post excerpt…”,
“post_status”: “publish”,
“comment_status”: “open”,
“ping_status”: “open”,
“post_password”: “”,
“post_name”: “example-post-title”,
“post_modified”: “2024-01-15 12:00:00”,
“post_modified_gmt”: “2024-01-15 12:00:00”,
“post_parent”: 0,
“menu_order”: 0,
“post_type”: “post”,
“featured_image”: “1042.featuredimage.jpg”,
“featured_image_id”: 523,
“post_meta”: {
“_edit_lock”: “1705318800:1”,
“_edit_last”: “1”,
“custom_field”: “custom value”
},
“taxonomies”: {
“category”: [
{
“term_id”: 5,
“name”: “News”,
“slug”: “news”,
“taxonomy”: “category”
}
],
“post_tag”: [
{
“term_id”: 12,
“name”: “WordPress”,
“slug”: “wordpress”,
“taxonomy”: “post_tag”
}
]
}
}
]
“`
## Key Features
1. **Git-like Pull/Push Workflow** – Familiar paradigm for developers
2. **Sequential Processing** – Stable, predictable operations
3. **Raw Content Preservation** – No HTML-to-Markdown conversion
4. **Complete Metadata** – Zero data loss, all postmeta included
5. **Featured Image Handling** – Full-size originals with smart change detection
6. **Taxonomy Support** – Preserves category and tag assignments
7. **Flexible Querying** – Standard WordPress query parameters supported
## Technical Details
– **Content Format**: Raw `post_content` saved as-is (no conversions)
– **File Naming**: Strict `[post_id].md` and `[post_id].featuredimage.[ext]` format
– **Working Directory**: All operations use `getcwd()` (current directory)
– **Image Handling**: Copies original files from WordPress uploads directory
– **Metadata**: Complete post object + all postmeta (flattened, unserialized)
– **Change Detection**: MD5 hashing for featured images to avoid unnecessary uploads
## Requirements
– WordPress 5.0+
– PHP 7.4+
– WP-CLI 2.0+
## License
Copyright (C) AI_PLUGIN_DEV 2026. ALL RIGHTS RESERVED. THIS IS NOT FREE SOFTWARE.
