-
Notifications
You must be signed in to change notification settings - Fork 8
/
single.php
executable file
·46 lines (39 loc) · 1.27 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
<?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 = Timber::query_post();
$context['post'] = $post;
$context['wp_title'] .= ' - ' . $post->title();
$context['comment_form'] = TimberHelper::get_comment_form();
// Adding some logic here - may be better in single-piece.php, but okay for now unless it gets more extensive.
if ( get_post_type() == 'piece') {
$terms = get_the_terms($post->ID, 'collection');
$piece_args = array(
'post_type' => 'piece',
'post__not_in' => array( $post->ID ),
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'collection',
'terms' => $terms[0],
'field' => 'id',
'operator' => 'IN'
)
)
);
$context['pieces'] = Timber::get_posts($piece_args);
$context['concierge_text'] = get_field('concierge_text', 'options');
}
if (post_password_required($post->ID)){
Timber::render('single-password.twig', $context);
} else {
Timber::render(array('singles/single-' . $post->ID . '.twig', 'singles/single-' . $post->post_type . '.twig', 'singles/single.twig'), $context);
}