-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle.php
54 lines (47 loc) · 1.59 KB
/
single.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
<?php
/**
* The Template for displaying all single posts
*
* Methods for TimberHelper can be found in the /functions sub-directory
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
$context = Timber::get_context();
$post = new TimberPost();
$context['post'] = $post;
// add page title
$context['wp_title'] = 'Pressenza - ' . $post->title();
// get author informations
$context['authorposts'] = count_user_posts($post->post_author);
$context['authoravatar'] = get_avatar($post->post_author, 70);
// get other languages of this post
$otherlanguages = '';
$languages = icl_get_languages('skip_missing=1');
if (1 < count($languages)) {
$langs = array();
foreach ($languages as $l) {
if (!$l['active']) {
$langs[] = '<a href="' . $l['url'] . '">' . $l['translated_name'] . '</a>';
}
}
$otherlanguages = implode(', ', $langs);
unset($langs);
}
$context['otherlanguages'] = $otherlanguages;
// get post categories
$postcategories = wp_get_post_categories($post->ID);
$cats = array();
$catexlude = array(11385, 11386, 11387, 11388, 11389, 11390, 19112);
$needles = array('@de', '@es', '@fr', '@pt');
foreach ($postcategories as $c) {
if (!in_array($c, $catexlude)) {
$cat = get_category($c);
$cats[] = '<a href="' . get_category_link($cat->term_id) . '">' . str_replace($needles, NULL, $cat->name) . '</a>';
}
}
$context['postcats'] = implode(', ', $cats);
// get post tags
$context['posttags'] = get_the_tag_list('Tags: ', ', ');
Timber::render('single.twig', $context);