Custom GPTs are powerful tools that can be tailored to perform specific tasks. One exciting use case is creating a GPT that acts as a journalist, writing and posting articles directly to a WordPress website. This guide walks you through the entire setup, from configuring your WordPress site to defining your GPT’s system prompt and integrating secure authentication.
Step 1: Enable REST API Access on WordPress
By default, WordPress includes a REST API. Most standard installations have it enabled out of the box. If you’re using custom security plugins or firewalls, ensure the following endpoints are accessible:
/wp-json/wp/v2/posts/wp-json/wp/v2/categories/wp-json/wp/v2/tags
Step 2: Generate an Application Password
WordPress allows you to create Application Passwords for secure API access without needing to use your main login credentials.
- Go to your WordPress Admin Dashboard.
- Navigate to Users > Profile (or any user with posting privileges).
- Scroll down to the Application Passwords section.
- Enter a name (e.g., “Custom GPT”) and click Generate New Password.
- Copy and securely store the generated password. You won’t see it again.
Step 3: Define Your JSON Schema
Your GPT will generate article content and send it to the WordPress REST API using a standard JSON schema. Here’s a boilerplate structure:
{
"title": "Sample Post Title",
"content": "<p>This is the article body in HTML format.</p>",
"status": "publish",
"categories": [1],
"tags": [2, 3],
"yoastFocusKeyword": "your focus keyword here",
"yoastMetaDescription": "A brief meta description under 155 characters."
}
You can adjust the status field to draft if you want to manually review posts before they go live.
Step 4: Setup Authentication
Use HTTP Basic Auth with the username and application password. You can send API requests using curl, Python, or JavaScript. Here’s a curl example:
curl -X POST https://yourwebsite.com/wp-json/wp/v2/posts
-u "yourusername:yourapplicationpassword"
-H "Content-Type: application/json"
-d @yourpost.json
Replace yourusername, yourapplicationpassword, and yourwebsite.com accordingly.
Step 5: Create a System Prompt for Your GPT
Here’s a boilerplate system prompt that you can customize for your GPT:
You are a professional AI journalist working for a website called "[Insert Website Name]". Your job is to write high-quality, engaging articles tailored to the topics relevant to this site. You are connected to the site's WordPress backend and can publish posts automatically.
Use the following JSON schema to format every article:
{
"title": "[Insert headline]",
"content": "[Insert HTML body]",
"status": "publish",
"categories": [1],
"tags": [2],
"yoastFocusKeyword": "[Insert focus keyword]",
"yoastMetaDescription": "[Insert SEO meta description]"
}
Ensure all content is in HTML. Use only pre-approved category and tag IDs as provided by the site owner. Do not fabricate categories or tags.
Optional: Define Categories and Tags
To avoid additional API calls for resolving names to IDs, the user should define and document the numeric IDs for allowed categories and tags. This can be included in the GPT system prompt or configuration file.
Conclusion
With just a small setup effort, you can transform a custom GPT into a content powerhouse that automatically generates and publishes content to your WordPress site. By using a standard JSON schema and leveraging the WordPress REST API with application passwords, the integration remains both secure and highly scalable.
