Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type:application/json');
- if(file_exists('../../../../wp-load.php')) :
- include '../../../../wp-load.php';
- else:
- include '../../../../../wp-load.php';
- endif;
- //$today6am = strtotime('today 6:00') + ( get_option( 'gmt_offset' ) * 3600 );
- global $wpdb;
- $args = array(
- 'posts_per_page' => -1,
- 'orderby' => 'post_date',
- 'order' => 'DESC',
- 'post_type' => 'course',
- 'meta_key' => '_uni_course-dates-start',
- );
- $events = get_posts( $args );
- $jsonevents = array();
- if ($events):
- global $post;
- foreach ($events as $post):
- setup_postdata($post);
- // - custom post type variables -
- $custom = get_post_custom(get_the_ID());
- $sd = $custom["_uni_course-dates-start"][0];
- $ed = $custom["_uni_course-dates-end"][0];
- // - grab gmt for start -
- $gmts = date('Y-m-d H:i:s', $sd);
- //$gmts = get_gmt_from_date($gmts); // this function requires Y-m-d H:i:s
- $gmts = strtotime($gmts);
- // - grab gmt for end -
- $gmte = date('Y-m-d H:i:s', $ed);
- //$gmte = get_gmt_from_date($gmte); // this function requires Y-m-d H:i:s
- $gmte = strtotime($gmte);
- // - set to ISO 8601 date format -
- $stime = date('c', $gmts);
- $etime = date('c', $gmte);
- $term = get_single_term($post->ID, 'course_locations');
- //$year = date('Y');
- //$month = date('m');
- // - json items -
- $jsonevents[]= array(
- 'title' => $post->post_title,
- 'allDay' => false, // <- true by default with FullCalendar
- 'start' => $stime,
- //'end' => $etime,
- 'className' => $term,
- 'url' => get_permalink($post->ID)
- );
- endforeach;
- else :
- endif;
- // - fire away -
- echo json_encode($jsonevents);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement