I’m requesting Content from WordPress by the “REST API V2” Plugin. This works great. There is just one problem left: Contents created by “VisualComposer” Plugin are not rendered in de REST Response.
Response is:
[vc_row]Hello World . . .[/vc_row]
Response should be:
<div class="row">Hello World . . .</div>
How can this be achieved??
Thank you?
I think you can find your answer here with WP REST API v2: https://github.com/WP-API/WP-API/issues/2578
The example below was taken from the link above (thank you, bradmsmith!)
Here is an example how to render the VC shortcodes on the content of a post:
EDIT
Here is the link for the register_rest_field() function: register_rest_field()
I have solved it by using another REST Plugin for WordPress (JSON API). This plugin renders the response as expected. The VisualComposer shortcodes are now in HTML.
That’s how Visual Composer stores the content. If you disable Visual Composer you’ll see that all it leaves behind is a series of shortcodes in every post you’ve used it on. The WP REST API doesn’t execute shortcodes before returning the stored content. You may want to look at page builders that write pure HTML instead of relying on shortcodes if you don’t want to have to transform the content after retrieving it, or you could create a custom endpoint for the WP REST API that runs the shortcode before returning the HTML.
It looks like they have an endpoint similar to what I’m recommending in the WP.com API, but nothing similar is in WP REST API yet, AFAIK.
There’s a great rundown of page builder plugins here, if you want to go that route.