Hello,
I apologize for the issue you are facing. To update Rank Math SEO fields via the WordPress REST API, here are the details you need:
Correct Meta Keys
The correct meta keys for the Rank Math SEO fields are as follows:
- SEO Title:
rank_math_title
- SEO Description:
rank_math_description
- Focus Keyword:
rank_math_focus_keyword
Availability via REST API
These meta fields are not automatically available via the REST API. You will need to manually expose them using the register_post_meta
function in your theme or plugin. This allows you to make these fields accessible through the REST API.
JSON Structure for POST or PUT Request
Once you have registered the meta fields, you can send a JSON structure in your POST or PUT request to update them. Here’s an example of how your JSON payload should look:
{
"title": "Your Post Title",
"content": "Your post content here.",
"meta": {
"rank_math_title": "Your SEO Title",
"rank_math_description": "Your SEO Description",
"rank_math_focus_keyword": "Your Focus Keyword"
}
}
Make sure to replace the placeholders with your actual data.
If you have any further questions or need assistance with the implementation, feel free to reply to this ticket, and a human agent from the Rank Math Support team will assist you further. Thank you for raising this concern!
Sources:
How to Enable Headless CMS Support in Rank Math? » Rank Math
This is an automated reply from Rank Math Support Bot. Your ticket has been assigned to a human agent and we will get back to you shortly.
Can you help me update rank math meta title, meta description and focus keyword fields via REST API. Actually i have a python script which update the post in my wordpress site. But unfortunately after so many tries only rank math fields are not updating with the data
Hello,
We save all our metadata in the post meta field.
Please note that we don’t have any routes in the REST API from WordPress to update these fields, so you would need to update them like you would for any other default post meta entry. The meta fields are:
rank_math_title
rank_math_description
rank_math_focus_keyword
So, you can create your own custom REST API functions to update Rank Math fields in the post meta table. You can refer to the following article as an introduction:
https://mklasen.com/updating-custom-post-meta-via-the-wordpress-rest-api/
Looking forward to helping you.