Key Corrections & Clarifications
- Get Pages + SEO Data
-
In WordPress, the SEO title & meta description are usually stored by an SEO plugin like Yoast SEO, Rank Math, or All in One SEO. These are custom fields, not part of the default post title.
-
So your workflow must read:
-
Page URL (slug or permalink)
-
Page’s focus keyword (if stored — e.g., Yoast stores it as _yoast_wpseo_focuskw)
-
SEO title (_yoast_wpseo_title)
-
SEO description (_yoast_wpseo_metadesc)
-
-
Correction: Make sure your API calls pull the custom fields for SEO data, not just the default post title/description.
-
Shortlist Pages
-
Filter only the pages where SEO title and/or SEO meta description is empty.
-
If the focus keyword is empty too, you might decide to skip that page or use a fallback keyword derived from the URL or content.
- Generate Title & Description
-
For each page with missing fields, send to ChatGPT:
-
Focus keyword
-
URL slug
-
Optional: page content or H1 for better context.
-
-
Prompt ChatGPT to generate a clear SEO title & meta description within best practices (e.g., title ~ 50-60 chars, description ~ 150-160 chars).
- Publish Updates
-
Use the WordPress REST API to update the post meta for each page.
-
You’ll need to use the update meta endpoint for custom fields.
- Logging & Error Handling
- Keep logs so you know which pages were updated.
If ChatGPT fails to generate a value, skip or flag for manual review.