-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpage.php
More file actions
executable file
·55 lines (46 loc) · 1.35 KB
/
page.php
File metadata and controls
executable file
·55 lines (46 loc) · 1.35 KB
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
<?php
/**
* The template for displaying all single pages
*
* https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage MGPress
* @version 1.0
* @since MGPress 1.0
* @author kchevalier@mindgruve.com
*/
// set context
$context = Timber::get_context();
$post = Timber::query_post();
$context['post'] = $post;
// custom template
$templateName = $post->meta('_wp_page_template') ? $post->meta('_wp_page_template') : null;
// controller (optional)
if (!is_null($templateName)) {
$controller = dirname(__FILE__) . '/controllers/' . $templateName . '.php';
if ($templateName && file_exists($controller)) {
include_once($controller);
}
}
// determine templates
if (post_password_required($post->ID)) {
$templates = array('detail/password.twig');
} else {
$templates = array(
'detail/page-' . $post->slug . '.twig',
'detail/page-' . $post->ID . '.twig',
'detail/page.twig',
'index.twig'
);
// add template if being used
if (!is_null($templateName)) {
array_unshift($templates, 'template/' . $templateName . '.twig');
}
// site front page template
if (is_front_page()) {
array_unshift($templates, 'detail/front-page.twig');
}
}
// render views
Timber::render($templates, $context);