/** * Make the custom popup content available in the REST API response. */ function expose_popup_content_in_rest_api() { register_rest_field( 'te_announcements', 'popup_content', array( 'get_callback' => function( $object, $field_name, $request ) { return get_post_meta( $object['id'], 'announcement_popup_content', true ); }, 'schema' => null, ) ); } add_action( 'rest_api_init', 'expose_popup_content_in_rest_api' );