3, 'post_type' => 'news', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => array(116), ), ), )); $featuredIDs = wp_list_pluck( $featured, 'id' ); $context['title'] = 'News'; $context['featured_ids'] = wp_list_pluck( $featured, 'id' ); $context['featured'] = $featured; $context['paged'] = $paged; if (!isset($paged) || !$paged){ $paged = 1; } $args = array( 'post_type' => 'news', 'posts_per_page' => 12, 'post__not_in' => array($featuredIDs[0]), 'paged' => $paged ); $context['posts'] = new Timber\PostQuery($args); } // Load categories for filter $context['categories'] = get_terms('category', array( 'hierarchical' => false, 'parent' => 0, 'hide_empty' => false, 'exclude' => array(1,116) )); } else if (is_post_type_archive( 'events' )) { $year = get_query_var('eventyear'); $month = get_query_var('eventmonth'); $day = get_query_var('eventday'); $location = get_query_var('eventlocation'); $date_now = date('Y-m-d'); if ($year && $month) { $title = date('F Y', strtotime($year . '-' . $month . '-01')); } else if ($year && $month && $day) { $title = date('jS F Y', strtotime($year . '-' . $month . '-'. $day)); } elseif ($location) { $title = 'Events at ' . get_the_title($location); } else { $title = 'Upcoming Events'; } $context['title'] = $title; // Get upcoming events, then group / sort by location $context['locations'] = bespoke_upcoming_events(); $context['location'] = $location; $context['latest'] = Timber::get_posts(array( 'posts_per_page' => 1, 'post_type' => 'events', 'meta_key' => 'date', 'meta_type' => 'DATE', 'meta_query' => array( array( 'key' => 'date', 'value' => $date_now, 'compare' => '>=', 'type' => 'DATE' ), ), 'order' => 'ASC', 'orderby' => 'meta_value' )); $template = array('archive-events.twig'); } else if (is_tax( 'county' )) { $template = array('archive-counties.twig'); // Filters $feature = $_GET['feature']; $args = false; if ($feature) { $context['feature'] = $feature; $args = array( 'post_type' => 'location', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'bh_sl_loc_cat', 'field' => 'slug', 'terms' => sanitize_title($feature), ), array( 'taxonomy' => 'county', 'field' => 'id', 'terms' => get_queried_object_id(), ), ), 'posts_per_page' => -1 ); } $context['locations'] = new Timber\PostQuery($args); // Title $context['title'] = get_queried_object()->name; // Description $context['description'] = term_description(); // Key $context['features'] = Timber::get_terms( array( 'taxonomy' => 'bh_sl_loc_cat', 'hide_empty' => false, 'exclude' => array(113,114,217) )); } Timber::render($template, $context);