Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // We'll assign the slug of a specific event category to this var
- $calendarTerm = null;
- // Have any of the pages we are interested in been requested?
- switch ($wp_query->post->post_name) {
- case 'peewee-schedule': $calendarTerm = 'peewee'; break;
- case 'bantam-schedule': $calendarTerm = 'bantam'; break;
- case 'midget-schedule': $calendarTerm = 'midget'; break;
- }
- // To help taxonomies persist over ajax requests
- if (defined('DOING_AJAX') and isset($_POST['customCalendarWidgetTax']))
- if (!empty($_POST['customCalendarWidgetTax'])) // Not if it's empty, thanks
- $calendarTerm = $_POST['customCalendarWidgetTax'];
- // Basic query
- $calendarQuery = array('eventDisplay' => 'month');
- // Create and use a tax query if we have a calendar term
- if ($calendarTerm !== null) {
- $taxonomyQuery = array('tax_query' => array(array(
- 'taxonomy' => TribeEvents::TAXONOMY,
- 'field' => 'slug',
- 'terms' => $calendarTerm
- )));
- $calendarQuery = array_merge($taxonomyQuery, $calendarQuery);
- }
- // Run the query
- $eventPosts = tribe_get_events($calendarQuery);
- // We need the category to persist across ajax requests
- $taxonomy = esc_attr($calendarTerm);
- echo '<input type="hidden" name="customCalendarWidgetTax" value="'.$taxonomy.'" />';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement