/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()) { $news = get_field('home_news', 'option'); $context['projects'] = Timber::get_posts(['numberposts' => -1, 'post_type' => 'project', 'post__in' => get_field('home_projects', 'option'), 'orderby' => 'post__in']); $context['news'] = $news ? new TimberPost($news) : Timber::get_post(['numberposts' => 1, 'post_type' => 'news']); $context['text'] = get_field('home_payoff', 'option'); $template = ['home.twig']; } else if (is_page()) { $context['post'] = new TimberPost(); $template = ['page.twig']; } else if (is_post_type_archive('project')) { $context['selection'] = new Timber\PostQuery(['post_type' => 'project', 'posts_per_page' => '-1', 'orderby' => 'post__in', 'post__in' => get_field('projects', 'option')]); $context['filters'] = Timber::get_terms('attribute'); $context['posts'] = new Timber\PostQuery(); $template = ['project-index.twig']; } else if (is_tax('theme')) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); $filters = array(); $context['posts'] = new Timber\PostQuery(); $context['term'] = new TimberTerm($term); foreach ($context['posts'] as $post) { $terms = wp_get_object_terms($post->ID, 'attribute'); $merge = array(); foreach ($terms as $term) { $merge[$term->slug] = $term; } $filters = array_merge($filters, $merge); } ksort($filters); $context['filters'] = $filters; $template = ['project-theme.twig']; } else if (is_tax('attribute')) { $url = get_post_type_archive_link('project'); wp_safe_redirect($url, 303); exit; } else if (is_singular('project')) { $context['post'] = new TimberPost(); $template = ['project-single.twig']; } else if (is_post_type_archive('news')) { $context['posts'] = new Timber\PostQuery(); $template = ['news-index.twig']; } else if (is_singular('news')) { $post = new TimberPost(); if (!$post->get_field('news_has_single')) { $url = get_post_type_archive_link('news'); wp_safe_redirect($url, 303); exit; } $context['post'] = $post; $template = ['news-single.twig']; } else if (is_post_type_archive('publication')) { $context['posts'] = new Timber\PostQuery(); $template = ['publication-index.twig']; } else if (is_singular('publication')) { $url = get_post_type_archive_link('publication'); wp_safe_redirect($url, 303); exit; } else if (is_search()) { $context['posts'] = new Timber\PostQuery(); $template = ['search.twig']; } else if (is_404()) { $template = ['errors/404.twig']; } Timber::render($template, $context); ?>