/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_page()) { $context['news'] = Timber::get_posts(['numberposts' => 3, 'post_type' => 'news']); $context['post'] = new TimberPost(); if (post_password_required($context['post']->ID)) { $template = 'page-password.twig'; } else { $template = [$context['post']->_wp_page_template . '.twig', 'page.twig']; } } else if (is_post_type_archive('event')) { $posts = new Timber\PostQuery(); $context['posts'] = $posts; $template = ['event-archive.twig']; } else if (is_singular('event')) { $context['post'] = new TimberPost(); $template = ['event-single.twig']; } else if (is_post_type_archive('location')) { $post_type = get_queried_object(); $page = get_page_by_path($post_type->rewrite['slug']); $context['page'] = new TimberPost($page->ID); $context['posts'] = new Timber\PostQuery(); $template = ['location-archive.twig']; } else if (is_singular('location')) { $post = new TimberPost(); $meta_query = [ between_program_dates_meta_query(), exclude_collection_children_meta_query(), ['key' => 'location', 'value' => $post->ID] ]; $context['events'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'event', 'meta_query' => $meta_query, 'meta_key' => 'performance_datetime', 'orderby' => ['meta_value' => 'asc']]); $context['locations'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'location']); $context['post'] = $post; $template = ['location-single.twig']; } else if (is_post_type_archive('news')) { $context['posts'] = new Timber\PostQuery(); $template = ['news-archive.twig']; } else if (is_singular('news')) { $post = new TimberPost(); $context['news'] = Timber::get_posts(['numberposts' => 3, 'post_type' => 'news', 'post__not_in' => [$post->ID]]); $context['post'] = $post; $template = ['news-single.twig']; } else if (is_search()) { $context['posts'] = new Timber\PostQuery(); $template = ['search.twig']; } else if (is_404()) { $template = ['errors/404.twig']; } Timber::render($template, $context); ?>