This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive.php
110 lines (83 loc) · 2.97 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* The template for displaying Archive pages.
*
* Used to display archive-type pages if nothing more specific matches a query.
* For example, puts together date-based pages if no date.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.2
*/
$archive = get_queried_object();
$taxonomy_name = $archive->taxonomy;
$templates = [
'archive-' . $taxonomy_name . '.twig',
'archive.twig',
'index.twig',
];
$context = Timber::context();
// Set vars
$context['title'] = get_the_archive_title();
if ( is_day() ) {
$context['title'] = sprintf( _x( 'Posts for %s.', 'Archive title for date: dag', 'gctheme' ), get_the_date( get_option('date_format') ) );
} elseif ( is_month() ) {
$context['title'] = sprintf( _x( 'Posts for %s.', 'Archive title for date', 'gctheme' ), get_the_date( 'F Y' ) );
} elseif ( is_year() ) {
$context['title'] = sprintf( _x( 'Posts for %s.', 'Archive title for date', 'gctheme' ), get_the_date( 'Y' ) );
}
// If term archive
if ( isset( $context['archive_term'] ) && ! empty( $context['archive_term']['descr'] ) ) {
$context['descr'] = $context['archive_term']['descr'];
}
$posts = new Timber\PostQuery();
// Set data for overview
$context['overview'] = [];
// Set data for tipkaarts
if ( $context['pagetype'] === 'archive_tipthema' ) {
// Set data for overview
$i = 0;
foreach ( $posts as $post ) {
$i ++;
$items[ $i ] = prepare_card_content( $post );
}
$context['overview']['items'] = $items;
$context['overview']['template'] = 'card--tipkaart';
$context['overview']['modifier'] = '4col';
} else {
foreach ( $posts as $post ) {
$context['items'][] = prepare_card_content( $post );
}
}
if ( $taxonomy_name === OD_CITAATAUTEUR ) {
// Get all data from the term
$cat = get_term( $archive->term_id );
$author = get_term_meta( $archive->term_id );
// Get fields
$image = get_field( 'tipgever_foto', $archive );
// Set up contact links
$contact = [];
$ci = 0;
if ( ! empty( $author['tipgever_telefoonnummer'][0] ) ) {
$contact['phone'] = $author['tipgever_telefoonnummer'][0];
}
if ( ! empty( $author['tipgever_mail'][0] ) ) {
$contact['email'] = $author['tipgever_mail'][0];
}
// Set author vars
$context['author']['title'] = $archive->name;
$context['author']['function'] = ( $author['tipgever_functietitel'][0] ? $author['tipgever_functietitel'][0] : '' );
$context['author']['image'] = ( $image ? $image['sizes']['medium'] : '' );
$context['author']['descr'] = ( $cat->description ? $cat->description : '' );
$context['author']['contact'] = ( $contact ? $contact : '' );
// Set overview
$fullname = explode( ' ', trim( $archive->name ) );
// Set 4 column grid for tipgevers. Default is col-3
$context['overview']['modifier'] = 'col-4';
$context['overview']['title'] = 'Tips van ' . $fullname[0];
}
Timber::render( $templates, $context );