/wp-admin/plugins.php'; return; } if (!class_exists('acf') ) { echo 'ACF not activated. Make sure you activate the plugin in /wp-admin/plugins.php'; return; } $context = Timber::get_context(); if (is_front_page()) { $context['featured'] = get_field('featured', 'option'); $context['blog'] = Timber::get_posts(['numberposts' => 3, 'post_type' => 'blog']); $context['news'] = Timber::get_posts(['numberposts' => 3, 'post_type' => 'news']); $template = ['home.twig']; } else if (is_post_type_archive('event') && !get_query_var('event_alphabetical')) { $posts = Timber::get_posts(); $context['posts'] = my_get_events($posts); $context['timetable'] = my_get_event_timetable($posts); $context['days'] = my_get_event_days($posts); $context['kijkwijzers'] = get_terms(['taxonomy' => 'kijkwijzer', 'hide_empty' => false]); $context['genres'] = get_terms(['taxonomy' => 'genre', 'hide_empty' => false]); $template = ['event-index.twig']; } else if ((is_post_type_archive('event') && get_query_var('event_alphabetical')) || is_tax('filter') || is_tax('genre') || is_tax('kijkwijzer')) { $tax_query = []; if (is_tax('filter')) { $tax_query = [['taxonomy' => 'filter', 'field' => 'slug', 'terms' => get_query_var('term')]]; } if (is_tax('genre')) { $tax_query = [['taxonomy' => 'genre', 'field' => 'slug', 'terms' => get_query_var('term')]]; } if (is_tax('kijkwijzer')) { $tax_query = [['taxonomy' => 'kijkwijzer', 'field' => 'slug', 'terms' => get_query_var('term')]]; } $posts = Timber::get_posts(['numberposts' => -1, 'post_type' => 'event', 'orderby' => 'title', 'order' => 'asc', 'tax_query' => $tax_query]); $context['posts'] = $posts; $template = ['event-alphabetical.twig']; } else if (is_singular('event')) { $post = Timber::query_post(); $context['performances'] = my_get_event_performances_per_day($post); $context['kijkwijzers'] = get_terms(['taxonomy' => 'kijkwijzer', 'hide_empty' => false]); $context['post'] = $post; $template = ['event-single.twig']; } else if (is_post_type_archive('education')) { $posts = Timber::get_posts(); $context['days'] = my_get_education_days($posts); $context['posts'] = $posts; $context['ages'] = get_terms(['taxonomy' => 'ages', 'hide_empty' => false]); $context['niveaus'] = get_terms(['taxonomy' => 'niveaus', 'hide_empty' => false]); $context['genres'] = get_terms(['taxonomy' => 'genres', 'hide_empty' => false]); $template = ['education-index.twig']; } else if (is_tax('genres') || is_tax('ages') || is_tax('niveaus') || is_year()) { $url = get_post_type_archive_link('education'); wp_safe_redirect($url); exit; } else if (is_singular('education')) { $context['ages'] = get_terms(['taxonomy' => 'ages', 'hide_empty' => false]); $context['niveaus'] = get_terms(['taxonomy' => 'niveaus', 'hide_empty' => false]); $context['post'] = Timber::query_post(); $template = ['education-single.twig']; } else if (is_page()) { $context['post'] = new TimberPost(); if ($context['post']->ID === $context['ticket']->ID) { $posts = Timber::get_posts(['numberposts' => -1, 'post_type' => 'event']); $context['posts'] = my_get_events($posts); $template = ['page-tickets.twig']; } else { $posts = Timber::get_posts(['numberposts' => -1, 'post_type' => 'event']); $context['posts'] = my_get_events($posts); $name = str_replace(['education', 'participate', 'staff'], ['scholen', 'doe-mee', 'medewerkers'], $context['post']->post_name); $template = ['page-' . $name . '.twig', 'page.twig']; } } else if (is_post_type_archive('blog')) { $context['posts'] = Timber::get_posts(); $template = ['blog-index.twig']; } else if (is_singular('blog')) { $context['post'] = Timber::query_post(); $template = ['blog-single.twig']; } else if (is_post_type_archive('backstage')) { $context['posts'] = Timber::get_posts(); $template = ['backstage-index.twig']; } else if (is_singular('backstage')) { $context['post'] = Timber::query_post(); $template = ['backstage-single.twig']; } else if (is_post_type_archive('news')) { $context['posts'] = Timber::get_posts(); $template = ['news-index.twig']; } else if (is_singular('news')) { $context['post'] = Timber::query_post(); $context['news'] = Timber::get_posts(['numberposts' => 4, 'post_type' => 'news', 'post__not_in' => [$context['post']->ID]]); $template = ['news-single.twig']; } else if (is_search()) { $context['posts'] = Timber::get_posts(); $template = ['search.twig']; } else if (is_404()) { $template = ['errors/404.twig']; } Timber::render($template, $context); ?>