admin管理员组文章数量:1426198
I am working on a WordPress project with a headless front end, and am looking for a way to expose the individual post blocks when hitting the revisions endpoint. /
I used this code to expose each block as array item in my API request. /
Now I am trying to do the same thing with the revisions endpoint. It only returns the rendered content as one long string, instead of individual blocks. Does anyone now if this is possible?
thanks!
I am working on a WordPress project with a headless front end, and am looking for a way to expose the individual post blocks when hitting the revisions endpoint. https://developer.wordpress/rest-api/reference/post-revisions/
I used this code to expose each block as array item in my API request. https://wpscholar/blog/add-gutenberg-blocks-to-wp-rest-api/
Now I am trying to do the same thing with the revisions endpoint. It only returns the rendered content as one long string, instead of individual blocks. Does anyone now if this is possible?
thanks!
Share Improve this question asked Jun 17, 2019 at 15:46 Anton EmeryAnton Emery 431 silver badge4 bronze badges 2 |1 Answer
Reset to default 0Figured it out, after half a day of banging away and asking a team mate. In the wpscholar link above I changed this line of code.
// Surface all Gutenberg blocks in the WordPress REST API
$post_types = get_post_types_by_support( [ 'editor' ] ); // change this line
$post_types = ['post', 'page', 'post-revision']; // to this
This targets the post-revision type and returns its content in Gutenberg blocks.
Hopefully this is helpful to someone
本文标签: Expose Gutenberg blocks in Post Revisions API endpoint
版权声明:本文标题:Expose Gutenberg blocks in Post Revisions API endpoint 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745392390a2656658.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
revision
post type rather than the revisions API endpoint. – Nathan Powell Commented Jun 17, 2019 at 16:02wp-json/wp/v2/posts/219/?_embed&type=revision
. Back to it... – Anton Emery Commented Jun 17, 2019 at 20:40