name; } $postType = get_post_type_object($postTypeSlug); $postTypeTitle = get_field($postTypeSlug . '_overview_title', 'option'); $context['title'] = !empty($postTypeTitle) ? $postTypeTitle : (is_object($postType) ? $postType->labels->name : $postTypeSlug); $paged = (int) get_query_var('paged', 1); $context['paged'] = $paged > 0 ? $paged : 1; $context['filters'] = apply_filters('stek_filters', [], $postType->name, true); $context['q'] = esc_html(@$_GET['q']); if ($context['paged'] === 1) { $featuredArgs = apply_filters('query_' . (str_replace('-', '_', $postType->name)), null); if (isset($featuredArgs['post__not_in'])) { $featuredArgs['posts_per_page'] = count($featuredArgs['post__not_in']); unset($featuredArgs['post__not_in']); $context['featuredPosts'] = Timber::get_posts($featuredArgs); } } $template = 'archive.twig'; if (file_exists(get_template_directory() . '/templates/archive-' . $postType->name . '.twig') || file_exists(get_stylesheet_directory() . '/templates/archive-' . $postType->name . '.twig')) { $template = 'archive-' . $postType->name . '.twig'; } $context['grid_class'] = 'background-last'; add_action('wp_enqueue_scripts', function () use ($postType) { wp_add_inline_script('g2p-ajax', 'const STEK_AJAX = ' . json_encode(['apiUrl' => RestAPI::$baseUrl . (str_replace('-', '', $postType->name)) . '/overview/']), 'before'); }, 10); } elseif (is_category() || is_tax()) { $context['title'] = single_cat_title(false, false); } elseif( is_tag() ) { $context['title'] = __('Tag: ', 'go2people') . single_tag_title(false, false); } elseif( is_day() ) { $context['title'] = $context['title'] . get_the_time('j F Y'); } elseif( is_month() ) { $context['title'] = $context['title'] . get_the_time('F Y'); } elseif( is_year() ) { $context['title'] = $context['title'] . get_the_time('Y'); } elseif( is_author() ) { $context['title'] = $context['title'] . get_the_author(); } else { $context['title'] = $context['title']; } Timber::render([$template], $context);