Visual Composer shortcodes are normally not converted within the WordPress REST API rendered output.
This can be accomplished by calling WPBMap::addAllMappedShortcodes();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
add_action( 'rest_api_init', function () { register_rest_field( 'page', 'content', array( 'get_callback' => 'convert_do_shortcodes', 'update_callback' => null, 'schema' => null, ) ); }); function convert_do_shortcodes( $object, $field_name, $request ) { WPBMap::addAllMappedShortcodes(); // This does all the work global $post; $post = get_post ($object['id']); $output['rendered'] = apply_filters( 'the_content', $post->post_content ); return $output; } |