Update Rank Math via n8n: 2 Methods That Actually Work
Contents
When I built SEVOsmith—my autonomous n8n system for AI-citable content—I hit an unexpected wall. The workflow could generate articles, upload to WordPress, attach featured images, and set categories. Everything worked. Except Rank Math stayed completely empty. SEO title, meta description, focus keyword—all blank.
I spent hours debugging. The n8n WordPress node was sending data correctly. WordPress was receiving it. But the Rank Math fields never populated. No error messages. No warnings. Just empty fields every single time.
The problem? WordPress’s REST API ignores custom meta fields by default. Rank Math stores SEO data in fields like rank_math_title, rank_math_description, and rank_math_focus_keyword—but WordPress treats these as private unless you explicitly register them for API access.
After testing multiple approaches, I found two solutions that actually work. I’m sharing both here: a plugin that handles everything automatically (5 minutes), and a native PHP method for those who prefer no external dependencies (15 minutes). Pick whichever fits your workflow.
Why Standard n8n – WordPress Integration Fails for Rank Math
The n8n WordPress node interacts with the core WordPress REST API. This API has a security feature that works against automation: it strictly ignores meta keys that haven’t been whitelisted with show_in_rest => true.
Rank Math stores SEO metadata in custom post meta fields. These fields exist in your database, but WordPress treats them as private. Your n8n workflow sends the data, WordPress receives it, and then silently drops it. No error message. No warning. Just empty fields.
The core problem: WordPress’s default security architecture blocks unregistered meta keys from REST API writes.
Two Solutions: Plugin vs. Native Code
Both methods achieve the same result—Rank Math fields populated via REST API. The difference is implementation complexity and dependencies.
Method 1: Helper Plugin
Install the rank-math-api-manager plugin from GitHub. It registers the meta keys automatically. Zero code changes required. The downside: you’re adding a third-party dependency that may not be maintained long-term.
- Setup time: 5 minutes
- Technical skill: Beginner-friendly
- Supports: Posts + WooCommerce Products
- Best for: Teams, managed hosting, quick deployment
Method 2: Native REST API (This Guide)
Register the meta keys yourself in your theme’s functions.php. Full control, no external dependencies, and built-in security layers. This is the cleaner approach for production workflows.
- Setup time: 15 minutes
- Technical skill: Comfortable with code
- Supports: Any post type (configurable)
- Best for: Developers, minimal dependencies, full control
Method 2: Native PHP Method (No Plugin)
This PHP snippet tells WordPress: “Allow the REST API to read and update these specific Rank Math fields, but only for authenticated users with edit permissions.”
Phase 1: WordPress Setup
- Step 1: Log into WordPress Dashboard
- Step 2: Navigate to Appearance → Theme File Editor
- Step 3: Select Theme Functions (functions.php) from the right sidebar
- Step 4: Scroll to the bottom of the file
- Step 5: Paste the secured code snippet
- Step 6: Click “Update File”
Troubleshooting: If you don’t see the Theme File Editor, your hosting may have disabled it for security. Use FTP or your hosting’s file manager instead. If you’re using a child theme, add the code to the child theme’s functions.php to survive parent theme updates.
Add this to your theme’s functions.php
/**
* Expose Rank Math SEO fields to REST API for n8n automation.
* Security: Only allows updates from authenticated users.
*/
add_action( 'rest_api_init', function () {
// List of Rank Math keys to expose
$keys = [
'rank_math_title',
'rank_math_description',
'rank_math_focus_keyword'
];
foreach ( $keys as $key ) {
register_meta( 'post', $key, [
// 1. Allow n8n to UPDATE the field
'show_in_rest' => [
'schema' => [
'type' => 'string',
'context' => ['edit'], // CRITICAL: Only visible in 'edit' context (authenticated)
],
],
'single' => true,
'type' => 'string',
// 2. Security Gate: Only allow users with edit permissions to update
'auth_callback'=> function() {
return current_user_can( 'edit_posts' );
},
// 3. Sanitization: Prevent script injection/XSS attacks
'sanitize_callback' => 'sanitize_text_field'
]);
}
});Three Security Layers Built In
1. context => [‘edit’]
The fields are invisible in public API responses. Competitors can’t scrape your focus keywords by hitting your REST API. Only authenticated requests (your n8n workflow with API credentials) can see or modify these fields.
2. auth_callback
Requires edit_posts capability. Even if someone has your API endpoint, they can’t write to these fields without proper WordPress user permissions.
3. sanitize_callback
Strips malicious code before saving. If your AI content generator accidentally produces <script>alert(‘hack’)</script> in a meta description, WordPress will clean it before it hits the database.
Phase 2: n8n Configuration
The standard WordPress node won’t work here because we need to send custom meta fields. Use an HTTP Request node instead with this configuration:
HTTP Request Node Settings:
Method: POST (new post) or PUT (update existing)
URL: https://yoursite.com/wp-json/wp/v2/posts
Authentication: Basic Auth (use Application Password)
Content-Type: application/jsonJSON Body Payload:
{
"title": "{{ $json.post_title }}",
"content": "{{ $json.post_content }}",
"status": "draft",
"meta": {
"rank_math_title": "{{ $json.seo_title }}",
"rank_math_description": "{{ $json.meta_description }}",
"rank_math_focus_keyword": "{{ $json.focus_keyword }}"
}
}Key detail: The meta field names in your payload (rank_math_title, etc.) must match exactly what you registered in PHP. No underscore prefix in the payload.
Example workflow:
Once you’ve enabled Rank Math API access, configure your n8n workflow to send SEO metadata. Below is a complete, ready-to-import workflow you can use as a starting point.
Copy the JSON below and import it into n8n (Settings → Import from File/URL → paste JSON). Then update the credentials and test values for your site.
{
"name": "Rank Math API Test",
"nodes": [
{
"parameters": {
"method": "POST",
"url": "={{ $json.target_domain }}/wp-json/wp/v2/posts/{{ $json.id }}",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "wordpressApi",
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "meta",
"value": "={{ { \"rank_math_title\": $json.meta_title, \"rank_math_description\": $json.meta_description, \"rank_math_focus_keyword\": $json.keyword } }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
224,
-336
],
"name": "Update Rank Math",
"id": "ab5352a8-bc6e-4a4f-ae07-595a789da96e",
"credentials": {
"wordpressApi": {
"id": "splT8wXfzOkGRMHQ",
"name": "Wordpress NextGrowth.AI"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"name": "target_domain",
"value": "https://yoursite.com",
"type": "string"
},
{
"name": "id",
"value": 123,
"type": "number"
},
{
"name": "meta_title",
"value": "Your SEO Title Here",
"type": "string"
},
{
"name": "meta_description",
"value": "Your meta description here",
"type": "string"
},
{
"name": "keyword",
"value": "your-focus-keyword",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
16,
-336
],
"name": "Prepare WordPress",
"id": "5ded5bd3-2439-4824-b14a-537a69375cfa"
}
],
"pinData": {},
"connections": {
"Prepare WordPress": {
"main": [
[
{
"node": "Update Rank Math",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1",
"availableInMCP": false
},
"versionId": "db537177-ea77-4384-b347-5f044459667e",
"meta": {
"instanceId": "ecafe3612490e54547497b912a5ff8791e237be1baa22093b760bb94e6a28be6"
},
"id": "DkjX2FL2nG8i7ha1",
"tags": []
}The workflow consists of two nodes: a Prepare WordPress node to prepare your data, and an HTTP Request node to send it to WordPress. This pattern works whether you’re updating an existing post or integrating into a larger content automation pipeline.
Node 1: Edit Fields (Prepare WordPress)
This node sets up the variables your HTTP Request needs. In a production workflow, these values would come from upstream nodes (AI content generator, Google Sheets, database query, etc.). For testing, we hardcode them.
Required Fields:
• target_domain – Your WordPress site URL (e.g., https://yoursite.com)
• id – The WordPress post ID to update
• meta_title – Your SEO title (what appears in search results)
• meta_description – Your meta description (155-160 characters)
• keyword – Your focus keyword for Rank Math analysisNode 2: HTTP Request (Send to WordPress)
This node sends the Rank Math metadata to WordPress via the REST API. Key configuration details:
Method: POST
URL Pattern:
={{ $json.target_domain }}/wp-json/wp/v2/posts/{{ $json.id }}The URL dynamically constructs the endpoint using your domain and post ID. This allows the same workflow to update any post on any WordPress site.
Authentication: WordPress API credentials (using n8n’s built-in WordPress credential type)
You’ll need to create WordPress credentials in n8n using an Application Password. Go to your WordPress profile (Users → Profile → Application Passwords) to generate one.
Body Parameter – The Meta Object:
The key to this integration is sending the meta parameter with Rank Math field mappings:
={{
{
"rank_math_title": $json.meta_title,
"rank_math_description": $json.meta_description,
"rank_math_focus_keyword": $json.keyword
}
}}Important: The field names (rank_math_title, etc.) must match exactly. No underscore prefix. Case-sensitive.
Setup Checklist
Before running the workflow:
- ☐ Install the Rank Math API Manager plugin OR add the PHP snippet
- ☐ Create WordPress API credentials in n8n (Credentials → New → WordPress API)
- ☐ Generate an Application Password in WordPress (Users → Profile)
- ☐ Update target_domain to your WordPress URL
- ☐ Update id to a real post ID from your site
- ☐ Assign your WordPress credentials to the HTTP Request node
Phase 3: Testing Your Setup
Trigger your n8n workflow with sample data, then open the created post. The Rank Math panel should show your SEO title, meta description, and focus keyword.

Method 1: Rank Math API Manager Plugin
If you can’t edit theme files (managed hosting restrictions, non-technical team), use the rank-math-api-manager plugin:
GitHub: https://github.com/devora-as/rank-math-api-manager
The plugin handles REST API registration automatically and supports both posts and WooCommerce products. Trade-off: you’re adding an external dependency that may not receive updates when WordPress or Rank Math release breaking changes.
What It Does
The plugin exposes these Rank Math fields to the WordPress REST API:
- rank_math_title – SEO Title
- rank_math_description – Meta Description
- rank_math_focus_keyword – Focus Keyword
- rank_math_canonical_url – Canonical URL
It works for both standard WordPress posts and WooCommerce products out of the box.
Plugin Installation
- Step 1: Download the plugin from GitHub (Code → Download ZIP)
- Step 2: In WordPress, go to Plugins → Add New → Upload Plugin
- Step 3: Upload the ZIP file and click Install Now
- Step 4: Activate the plugin
That’s it. No configuration needed. The plugin starts working immediately.
Which Method Should You Choose?
Use the Rank Math API Manager Plugin if:
- You’re on managed hosting without file access
- Your team includes non-technical members
- You need WooCommerce product support
- You want the fastest deployment
Use the Native PHP Method if:
- You prefer zero external dependencies
- You need custom field configurations
- You’re comfortable editing theme files
For most n8n automation workflows, the plugin is the pragmatic choice. It’s maintained, tested, and handles edge cases you might not anticipate. The native method is there when you need full control.
Conclusion
WordPress blocks Rank Math metadata updates via REST API by default—but now you have two working solutions. The Rank Math API Manager plugin gets you running in 5 minutes with zero code. The native PHP method gives you full control with built-in security.
Your n8n → WordPress automation pipeline can now handle SEO metadata the same way it handles everything else: completely hands-off.
