{\rtf1\ansi\ansicpg1252\cocoartf2867 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Arial-BoldMT;} {\colortbl;\red255\green255\blue255;\red1\green22\blue40;\red255\green255\blue255;} {\*\expandedcolortbl;;\cssrgb\c0\c11373\c20784;\cssrgb\c100000\c100000\c100000;} \paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0 \deftab720 \pard\pardeftab720\partightenfactor0 \f0\b\fs32 \cf2 \cb3 \expnd0\expndtw0\kerning0 \outl0\strokewidth0 \strokec2 'tribe_events',\ 'posts_per_page' => $count,\ 'post_status' => 'publish',\ 'orderby' => 'meta_value',\ 'meta_key' => '_EventStartDate',\ 'order' => 'ASC',\ );\ \ if ( $category ) \{\ $args['tax_query'] = array(array(\ 'taxonomy' => 'tribe_events_cat',\ 'field' => 'slug',\ 'terms' => $category,\ ));\ \}\ \ $meta_query = array();\ if ( $start ) \{\ $meta_query[] = array(\ 'key' => '_EventStartDate',\ 'value' => $start . ' 00:00:00',\ 'compare' => '>=',\ 'type' => 'DATETIME',\ );\ \}\ if ( $end ) \{\ $meta_query[] = array(\ 'key' => '_EventStartDate',\ 'value' => $end . ' 23:59:59',\ 'compare' => '<=',\ 'type' => 'DATETIME',\ );\ \}\ if ( $meta_query ) \{\ $args['meta_query'] = $meta_query;\ \}\ \ $query = new WP_Query( $args );\ $out = array();\ if ( $query->have_posts() ) \{\ while ( $query->have_posts() ) \{\ $query->the_post();\ $post_id = get_the_ID();\ $start_date = function_exists('tribe_get_start_date') ? tribe_get_start_date($post_id, false, 'c') : get_post_meta($post_id, '_EventStartDate', true);\ $out[] = array(\ 'title' => get_the_title(),\ 'link' => get_permalink(),\ 'start' => $start_date,\ 'excerpt' => get_the_excerpt(),\ );\ \}\ \}\ wp_reset_postdata();\ echo json_encode($out, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);\ exit;\ }