-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.php
More file actions
44 lines (37 loc) · 1.28 KB
/
page.php
File metadata and controls
44 lines (37 loc) · 1.28 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
<?php
/**
*
* Page template
*
* Checks pagename in WP query_var.
* Looks for template based on pagename.
* Looks for original languages pagename template if WPML plugin installed.
* Falls back to standard get_template_part.
*
* @package Tofino
* @since 1.0.0
*/
use \Tofino\Helpers as h;
$template = h\get_page_name();
$parent_template = 'parent';
if ($post->post_parent) {
$ancestors = get_post_ancestors($post->ID);
$root = count($ancestors) - 1;
$parent = $ancestors[$root];
$parent_template = h\get_page_name($parent);
}
get_header();
if (locate_template('templates/content-page-' . $template . '.php') != '') {
get_template_part('templates/content-page', $template); // e.g. templates/content-page-members.php
} else if(locate_template('templates/content-page-' . $parent_template . '.php') != '') {
get_template_part('templates/content-page', $parent_template); // e.g. templates/content-page-members.php
} else {
if (function_exists('icl_object_id')) { //WPML installed
$original_page_id = apply_filters('wpml_object_id', get_the_ID(), 'page', false, 'en'); //Assumes english is the primary language.
if ($original_page_id) {
$template = h\get_page_name($original_page_id);
}
}
get_template_part('templates/content-page', $template);
}
get_footer(); ?>