REST API and shortcodes
-
I’m using this great plugin for my project and now I need to make it work with a mobile app via REST API.
It works but shortcodes won’t be decoded. I tried the following snippet to do this:
add_action( 'rest_api_init', function () { register_rest_field( 'page', 'content', array( 'get_callback' => 'sff_do_shortcodes', 'update_callback' => null, 'schema' => null, ) ); register_rest_field( 'event', 'content', array( 'get_callback' => 'sff_do_shortcodes', 'update_callback' => null, 'schema' => null, ) ); }); function sff_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; }
…and it works for pages and posts, but not for events.
Please help!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘REST API and shortcodes’ is closed to new replies.