Title: pull data from booking database with ShortCodes or API
Last modified: May 25, 2023

---

# pull data from booking database with ShortCodes or API

 *  Resolved [thomasnordic](https://wordpress.org/support/users/thomasnordic/)
 * (@thomasnordic)
 * [3 years ago](https://wordpress.org/support/topic/pull-data-from-booking-database-with-shortcodes-or-api/)
 * Hello! Always fantastic support. We have our [http://www.risoya.no](http://www.risoya.no)
   site up and running. Recieving bookings. Syncing with Airbnb.
 * Is there a way to pull data from the database with bookings and display on a 
   page (password protected). I want to create a simple overview for cleaning lists,
   numbers of towels needed, moving in moving out and more.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fpull-data-from-booking-database-with-shortcodes-or-api%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Roland Murg](https://wordpress.org/support/users/murgroland/)
 * (@murgroland)
 * [3 years ago](https://wordpress.org/support/topic/pull-data-from-booking-database-with-shortcodes-or-api/#post-16770303)
 * Hey [@thomasnordic](https://wordpress.org/support/users/thomasnordic/),
 * You can add the code below to your theme’s functions.php file. It will create
   a shortcode that you can add on any page to display future bookings. You can 
   also include details such form data by searching for a field’s value.
 *     ```wp-block-code
       add_shortcode('wpbs-bookings', function ($atts, $content = null) {
           $bookings = wpbs_get_bookings(array('calendar_id' => $atts['calendar_id'], 'orderby' => 'start_date', 'order' => 'asc'));
           $output = '<div class="wpbs-custom-bookings">';
           foreach ($bookings as $booking) {
               if (strtotime($booking->get('start_date')) < current_time('timestamp')) {
                   continue;
               }
   
               $fields = $booking->get('fields');
   
               $name = $fields[array_search('155', array_column($fields, 'id'))]['user_value']; // 155 is the form field ID for the "name" field.
   
               $output .= '<div class="wpbs-custom-booking">'
                . date('d.m.', strtotime($booking->get('start_date'))) . ' - '
                . date('d.m.y', strtotime($booking->get('end_date'))) . ': '
                . $name .
               '</div>';
           }
           $output .= '</div>';
           return $output;
       });
       ```
   
 *  Thread Starter [thomasnordic](https://wordpress.org/support/users/thomasnordic/)
 * (@thomasnordic)
 * [3 years ago](https://wordpress.org/support/topic/pull-data-from-booking-database-with-shortcodes-or-api/#post-16770504)
 * Thank you. I will need my IT friend to help me with that. Testing soon.

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

The topic ‘pull data from booking database with ShortCodes or API’ is closed to 
new replies.

 * ![](https://ps.w.org/wp-booking-system/assets/icon-256x256.gif?rev=2691961)
 * [WP Booking System - Booking Calendar](https://wordpress.org/plugins/wp-booking-system/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-booking-system/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-booking-system/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-booking-system/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-booking-system/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-booking-system/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [thomasnordic](https://wordpress.org/support/users/thomasnordic/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/pull-data-from-booking-database-with-shortcodes-or-api/#post-16770504)
 * Status: resolved