Title: REST API and shortcodes
Last modified: July 23, 2018

---

# REST API and shortcodes

 *  Resolved [nessunluogo](https://wordpress.org/support/users/nessunluogo/)
 * (@nessunluogo)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/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)

 *  [Ed](https://wordpress.org/support/users/erishel/)
 * (@erishel)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/rest-api-and-shortcodes/#post-10523522)
 * Hey there !
 * Thanks for reaching out.
 * Here’s an article that gives some great info about [The Events Calendar’s](https://theeventscalendar.com/product/wordpress-events-calendar/)
   REST API → [https://theeventscalendar.com/knowledgebase/introduction-events-calendar-rest-api/](https://theeventscalendar.com/knowledgebase/introduction-events-calendar-rest-api/)
 * Hope that helps!
 *  Thread Starter [nessunluogo](https://wordpress.org/support/users/nessunluogo/)
 * (@nessunluogo)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/rest-api-and-shortcodes/#post-10523572)
 * Hi Ed, thanks for your answer. I’ve already read the REST API article and it’s
   working but shortcodes are not decoded and I get many [things] instead of HTML.
 * I hope this can clear my question.
 *  [Ed](https://wordpress.org/support/users/erishel/)
 * (@erishel)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/rest-api-and-shortcodes/#post-10538424)
 * That shortcode function seems to be a workaround for when Visual Composer does
   not correctly display their shortcodes.
 * Without using function add_shortcode, the no custom shortcode is being created.
   Take a look at the WordPress doc that talks about the shortcode API → [https://codex.wordpress.org/Shortcode_API](https://codex.wordpress.org/Shortcode_API)
 *  Thread Starter [nessunluogo](https://wordpress.org/support/users/nessunluogo/)
 * (@nessunluogo)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/rest-api-and-shortcodes/#post-10545538)
 * Thank you!
    I’ll watch for a solution with Shortcode API
 *  [Ed](https://wordpress.org/support/users/erishel/)
 * (@erishel)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/rest-api-and-shortcodes/#post-10567227)
 * No problem!
 * Many of our users have used REST with shortcodes, you just have to make sure 
   that the shortcodes are “added” within your code.
 *  [Ed](https://wordpress.org/support/users/erishel/)
 * (@erishel)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/rest-api-and-shortcodes/#post-10604531)
 * Hi!
 * Not much has happened within this topic, so I’m marking it as resolved.
 * Don’t hesitate to reach out any time you need more help.
 * Cheers,
    Ed ✌️

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘REST API and shortcodes’ is closed to new replies.

 * ![](https://ps.w.org/the-events-calendar/assets/icon-256x256.gif?rev=2516440)
 * [The Events Calendar](https://wordpress.org/plugins/the-events-calendar/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/the-events-calendar/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/the-events-calendar/)
 * [Active Topics](https://wordpress.org/support/plugin/the-events-calendar/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/the-events-calendar/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/the-events-calendar/reviews/)

## Tags

 * [events](https://wordpress.org/support/topic-tag/events/)
 * [rest](https://wordpress.org/support/topic-tag/rest/)

 * 6 replies
 * 2 participants
 * Last reply from: [Ed](https://wordpress.org/support/users/erishel/)
 * Last activity: [7 years, 9 months ago](https://wordpress.org/support/topic/rest-api-and-shortcodes/#post-10604531)
 * Status: resolved