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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745392390a4625722.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