> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mavera.io/llms.txt
> Use this file to discover all available pages before exploring further.

# WordPress

> 5 production-ready jobs — blog content brand voice extraction, content audit refresh pipeline, category gap analysis with focus groups, Mavera-to-WordPress publish pipeline, and page performance focus group analysis

WordPress is where your content lives — blog posts, pages, categories, and the editorial rhythm that defines your brand online. These five jobs bridge that content layer with Mavera's surfaces (Brand Voices, Responses, Personas, Focus Groups, Generations) so your brand voice is grounded in what you've already published, stale content gets flagged and refreshed, category gaps are validated by synthetic audiences, new content publishes back as drafts with voice consistency, and engagement patterns inform future strategy.

***

## API Reference Card

| Detail          | Value                                                                                 |
| --------------- | ------------------------------------------------------------------------------------- |
| **Base URL**    | `https://{domain}/wp-json/wp/v2/`                                                     |
| **Auth**        | Application Passwords (Basic auth), OAuth 2.0, or JWT                                 |
| **Rate limits** | Server-dependent; no official WordPress.org cap — self-hosted varies by host          |
| **Pagination**  | `per_page` (max 100), `page` param; total in `X-WP-Total` / `X-WP-TotalPages` headers |
| **Mavera base** | `https://app.mavera.io/api/v1`                                                        |
| **Mavera auth** | `Authorization: Bearer mvra_live_...`                                                 |

<Info>
  All examples use four environment variables: `WORDPRESS_URL` (your site root, e.g. `https://blog.example.com`), `WORDPRESS_USER` (admin username for write operations), `WORDPRESS_APP_PASSWORD` (Application Password generated in Users → Profile → Application Passwords), and `MAVERA_API_KEY`. Reading public content does not require auth. Writing (creating/updating posts) requires Basic auth with the Application Password. Python examples use `requests`; JavaScript examples use `fetch`.
</Info>

***

## Prerequisites

<Steps>
  <Step title="WordPress site with REST API enabled">
    The REST API is enabled by default on WordPress 4.7+. Verify by visiting `https://yoursite.com/wp-json/wp/v2/posts` in a browser — you should see JSON. If you get a 404, check your permalink settings (Settings → Permalinks → choose anything other than "Plain") and ensure no security plugin is blocking the REST API.
  </Step>

  <Step title="Create an Application Password">
    In WordPress Admin, go to Users → Profile → scroll to **Application Passwords**. Enter a name (e.g. "Mavera Integration") and click **Add New Application Password**. Copy the generated password immediately — it won't be shown again. This password is used with your username for Basic auth on write operations.
  </Step>

  <Step title="Mavera API key">
    Get your key from [Mavera dashboard](https://app.mavera.io/settings/api-keys). The key starts with `mvra_live_`.
  </Step>

  <Step title="Install dependencies">
    ```bash theme={"dark"}
    pip install requests openai beautifulsoup4
    ```
  </Step>

  <Step title="Environment variables">
    ```bash theme={"dark"}
    export WORDPRESS_URL="https://blog.example.com"
    export WORDPRESS_USER="admin"
    export WORDPRESS_APP_PASSWORD="xxxx xxxx xxxx xxxx xxxx xxxx"
    export MAVERA_API_KEY="mvra_live_xxxxx"
    ```
  </Step>
</Steps>

***

## Jobs

| # | Job                                                       | WordPress Data                    | Mavera Surface             | Output                                      |
| - | --------------------------------------------------------- | --------------------------------- | -------------------------- | ------------------------------------------- |
| 1 | [Blog Content → Brand Voice Extraction](blog-brand-voice) | Published posts (title + content) | Brand Voices               | Voice profile capturing blog tone           |
| 2 | [Content Audit → Refresh Pipeline](content-audit-refresh) | All posts with dates + categories | Responses + Generations    | Prioritized refresh plan + updated outlines |
| 3 | [Category Gap Analysis](category-gap-analysis)            | Categories with post counts       | Personas + Focus Groups    | Validated content gap priorities            |
| 4 | [WordPress → Mavera Publish Pipeline](publish-pipeline)   | Existing brand voice + persona    | Responses → WordPress POST | Draft post published to WordPress           |
| 5 | [Page Performance → Focus Group](page-focus-group)        | Posts with comment counts + dates | Personas + Focus Groups    | Audience insights on content resonance      |

***

## Rate Limits & Production Notes

| Concern               | WordPress Limit                     | Recommendation                                                             |
| --------------------- | ----------------------------------- | -------------------------------------------------------------------------- |
| **REST API rate**     | Server-dependent (no official cap)  | Add 200ms delay between requests; respect `Retry-After` headers if present |
| **Pagination max**    | 100 items per page (`per_page=100`) | Always paginate with `X-WP-TotalPages` header check                        |
| **Auth for reads**    | Not required for public content     | Only use Basic auth for write operations                                   |
| **Auth for writes**   | Application Password (Basic auth)   | Never commit credentials; use env vars or secrets manager                  |
| **Mavera rate limit** | Varies by plan                      | Exponential backoff on `429` responses                                     |

<Warning>
  **Before going to production:** store `WORDPRESS_APP_PASSWORD` and `MAVERA_API_KEY` in a secrets manager (never commit them), implement rate limiting with delays between WordPress requests (your host may throttle aggressive API usage), use `_fields` parameter to limit response size and reduce server load, test write operations on a staging site first, validate generated HTML content before publishing, and set `status: "draft"` — never auto-publish without human review.
</Warning>

### Production Checklist

* [ ] Credentials in env vars or secrets manager — never in code
* [ ] Rate limiting with 200ms+ delays between WordPress API calls
* [ ] `_fields` parameter on all GET requests to reduce payload size
* [ ] Pagination handling with `X-WP-TotalPages` header
* [ ] HTML sanitization on generated content before WordPress POST
* [ ] Write operations tested on staging/development site first
* [ ] All auto-generated posts set to `status: "draft"` for editorial review
* [ ] Error logging and alerting for failed API calls
* [ ] Application Password scoped to minimum required capabilities

***

<CardGroup cols={2}>
  <Card title="WordPress REST API Handbook" href="https://developer.wordpress.org/rest-api/" icon="wordpress">
    Official reference for all endpoints, authentication, and pagination.
  </Card>

  <Card title="Mavera API Reference" href="https://app.mavera.io/docs/api" icon="book">
    Personas, focus groups, brand voices, and generations.
  </Card>

  <Card title="Application Passwords Guide" href="https://make.wordpress.org/core/2020/11/05/application-passwords-integration-guide/" icon="key">
    Setup guide for WordPress Application Passwords.
  </Card>

  <Card title="Integration Quick Reference" href="/cookbooks/integration-quick-reference" icon="bolt">
    Cross-platform patterns for all Mavera integrations.
  </Card>
</CardGroup>
