'post', 'posts_per_page' => 9, 'paged' => $paged ); $context['posts'] = Timber::get_posts( $args ); $template = '04-templates/overview-default/overview-default.twig'; } /* * Search results Template */ elseif ( is_search() ) { global $query_string; if ( !empty( get_search_query() ) ) { wp_parse_str( $query_string, $search_query ); $context['items'] = Timber::get_posts( $search_query ); $context['search_query'] = get_search_query(); if ( $context['search_query'] !== '' ) { $context['results_count'] = $context['posts']->found_posts; } else { $context['results_count'] = 0; } } $template = '04-templates/search-results/search-results.twig'; } /* * Archive Templates */ elseif ( is_archive() ) { // Timber::get_post() returns null when the archive query comes back // empty (e.g. a category term whose only attached post isn't queried by // a default category archive, such as a custom post type post - WP still // counts it toward the term, so the archive is served with a 200 instead // of a 404). Guard against that so ->title below doesn't fatal on null. $context['post'] = Timber::get_post() ?? (object) array( 'title' => '' ); /* * Blog Category */ if ( is_category() ) { $context['taxonomy'] = 'category'; $context['post']->title = get_the_archive_title(); $template = '04-templates/overview-default/overview-default.twig'; } /* * Blog Overview Page */ elseif ( is_post_type_archive( 'blog' ) ) { $context['post']->title = get_the_archive_title(); $template = '04-templates/overview-default/overview-default.twig'; } elseif ( is_tag() ) { $context['post']->title = get_the_archive_title(); $template = '04-templates/overview-default/overview-default.twig'; } elseif ( is_author() ) { $context['post']->title = 'Posts by: ' . get_the_author(); $template = '04-templates/overview-default/overview-default.twig'; } elseif ( is_date() ) { $context['post']->title = get_the_archive_title(); $template = '04-templates/overview-default/overview-default.twig'; } } Timber::render( array( $template . '', 'base-page.twig' ), $context );