---
name: wordpress-publisher
description: Publishes and manages content on WordPress sites with full REST API integration. Use when publishing articles to WordPress or managing WordPress content.
argument-hint: "[file.md] [--status=draft] [--category=blog]"
allowed-tools: [Read, Write, Bash, mcp__myaidev_wordpress__*]
disable-model-invocation: true
---

# WordPress Publisher Skill

Publish and manage content on WordPress sites using the WordPress REST API with session management and full MCP integration.

## Capabilities

- Publish markdown content as WordPress posts/pages
- Create drafts for review before publishing
- Manage categories, tags, and featured images
- Update existing posts
- Session management for secure API access
- Health checks and connection validation

## Prerequisites

Configure WordPress credentials using the configure skill:

```
/myaidev-method:configure wordpress
```

Or set environment variables manually:
```
WORDPRESS_URL=https://your-site.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx
```

### Creating an Application Password

1. Log into WordPress admin
2. Go to Users → Profile
3. Scroll to "Application Passwords"
4. Enter a name (e.g., "MyAIDev Method")
5. Click "Add New Application Password"
6. Copy the generated password (shown only once)

## MCP Tools Available

| Tool | Description |
|------|-------------|
| `wp_session_create` | Create authenticated session |
| `wp_session_status` | Get session info and operation history |
| `wp_health_check` | Verify connection and authentication |
| `wp_get_site_info` | Get site statistics and version info |
| `wp_create_post` | Create new post from markdown |
| `wp_update_post` | Update existing post |
| `wp_delete_post` | Delete post (move to trash) |
| `wp_list_posts` | List posts with filters |
| `wp_list_users` | Get user accounts and roles |
| `wp_create_user` | Add new user account |
| `wp_update_user` | Modify user settings |
| `wp_list_plugins` | Get installed plugins |
| `wp_get_media` | Access media library |
| `wp_batch_publish` | Batch publish multiple posts |
| `wp_memory_store` | Store data in memory |
| `wp_memory_retrieve` | Retrieve stored data |
| `wp_memory_list` | List stored data in namespace |

## Process

1. **Session Creation**: Authenticate with WordPress
2. **Content Parsing**: Extract frontmatter and content from markdown
3. **Media Upload**: Upload any referenced images
4. **Post Creation**: Create post via REST API
5. **Verification**: Confirm successful publication
6. **URL Return**: Provide the published/draft URL

## Markdown Format

Content should include frontmatter:

```markdown
---
title: Your Post Title
meta_description: SEO description (optional)
slug: url-friendly-slug (optional)
tags: [tag1, tag2] (optional)
featured_image: ./path/to/image.png (optional)
---

# Your Post Title

Your content here...
```

## Parameters

| Parameter | Description | Default |
|-----------|-------------|---------|
| `file` | Path to markdown file | Required |
| `--status` | draft, publish, pending, private | draft |
| `--category` | Post category | Uncategorized |
| `--tags` | Comma-separated tags | none |
| `--author` | Author ID | current user |
| `--featured-image` | Path to featured image | none |

## Example Usage

```bash
# Publish as draft
/myaidev-method:wordpress-publish "./content/my-article.md" --status=draft

# Publish immediately
/myaidev-method:wordpress-publish "./content/my-article.md" --status=publish --category=tutorials

# With featured image
/myaidev-method:wordpress-publish "./content/my-article.md" --featured-image="./images/hero.png"
```

## Integration

- Works with `/myaidev-method:content-writer` via `--publish-wordpress` flag
- Works with `/myaidev-method:coordinate-content` for batch publishing
- Supports content verification before publishing

## Gutenberg Block Support

The publisher automatically converts markdown to Gutenberg blocks:

- Headings → `core/heading`
- Paragraphs → `core/paragraph`
- Code blocks → `core/code`
- Images → `core/image`
- Lists → `core/list`
- Blockquotes → `core/quote`
- Tables → `core/table`

## Error Handling

| Error | Solution |
|-------|----------|
| 401 Unauthorized | Check credentials, regenerate app password |
| 403 Forbidden | Verify user has publish_posts capability |
| Connection refused | Check WordPress URL and server status |
| Media upload failed | Check file permissions and upload limits |

## Security Notes

- Never commit credentials to version control
- Use application passwords instead of main password
- Store credentials in `.env` file (add to `.gitignore`)
- Use HTTPS for all WordPress connections
