-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive.php
39 lines (35 loc) · 1.38 KB
/
archive.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
$templates = array('archive.twig', 'index.twig');
$context = Timber::context();
switch (true) {
case is_category():
$title = sprintf(__("Catégorie : %s"), single_tag_title('', false));
array_unshift($context, "archive-" . get_query_var('cat') . ".twig");
break;
case is_tag():
$title = sprintf(__("Étiquette : %s"), single_tag_title('', false));
array_unshift($context, "archive-" . get_query_var('tag') . ".twig");
break;
case is_author():
$title = sprintf(__("Auteur : %s"), get_the_author_meta('display_name'));
array_unshift($context, "archive-" . get_the_author_meta("nicename") . ".twig");
break;
case is_day():
$title = ucfirst(get_the_date(_x('d F Y', "Format a date to display day in full letter", "CustomThemeName")));
break;
case is_month():
$title = ucfirst(get_the_date(_x('F Y', "Format a date to display month in full letter", "CustomThemeName")));
break;
case is_year():
$title = get_query_var('year');
break;
case is_post_type_archive():
$title = get_query_var('year');
array_unshift($context, "archive-" . get_post_type() . ".twig");
break;
default:
$title = get_the_archive_title();
}
$context['title'] = $title;
$context['posts'] = new Timber\PostQuery();
Timber::render($templates, $context);