We have a headless Wordpress CMS hosted on wordpress.com, and I am having trouble retrieving Yoast SEO tags using the Wordpress API.
The vanilla Wordpress API uses URLs like so:
https://example.com/wp-json/wp/v2/posts/1
but on sites hosted on wordpress.com they are rather different:
public-api.wordpress.com/rest/v1.1/sites/example.wordpress.com/posts/1
I have two possibly-related issues:
I believe solving either of the issues would be enough for us to get the tags needed. We're using Yoast 18.0, the Yoast output does appear in directly-rendered pages, and the Yoast REST API head endpoint is switched on in settings.
I have been able to solve this on our production site very simply: the normal API paths do in fact work (at least the /v2/
paths) for our production site.
It seems that the path transformation only applies to the free/cheaper hosting packages on wordpress.com. We are using a free site as an integration testing target so in fact this only fails in testing, not in production with a paid wordpress.com package.
Presumably this is because the cheaper packages are all on some kind of shared instance: when we initially upgraded it did not help, but when we installed Yoast it moved us to a different subdomain and the normal API paths started working. I guess at this point we had been moved to a dedicated instance.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.