-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpage.php
65 lines (59 loc) · 1.8 KB
/
page.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
<?php
get_header();
// 将当前文章设置为全局变量
the_post();
// 页面banner
pageBanner();
?>
<div class="container container--narrow page-section">
<?php
$self_id = get_the_ID();
$parent_post_id = wp_get_post_parent_id($self_id);
if ($parent_post_id) {
?>
<div class="metabox metabox--position-up metabox--with-home-link">
<p>
<a
class="metabox__blog-home-link"
href="<?php echo get_permalink($parent_post_id); ?>"
>
<i class="fa fa-home" aria-hidden="true"></i>
返回<?php echo get_the_title($parent_post_id); ?>
</a>
<span class="metabox__main"><?php echo the_title(); ?></span>
</p>
</div>
<?php } ?>
<?php
// 如果页面有父页面或者页面有子页面,则展示子页面菜单
if ($parent_post_id || get_pages(['child_of' => $self_id])) {
?>
<div class="page-links">
<h2 class="page-links__title"><a href="<?php echo get_permalink($parent_post_id); ?>"><?php echo get_the_title($parent_post_id); ?></a></h2>
<ul class="min-list">
<?php
// 当前页面有父级页面时,展示父级页面的子页面
// 否则展示当前页面的子页面
if ($parent_post_id) {
$thisChildOf = $parent_post_id;
} else {
$thisChildOf = $self_id;
}
wp_list_pages(
array(
'title_li' => null, // 不显示pages字段
'child_of' => $thisChildOf,
'sort_column' => 'menu_order', // 使用页面属性排序
)
);
?>
</ul>
</div>
<?php } ?>
<div class="generic-content">
<?php the_content(); ?>
</div>
</div>
<?php
get_footer();
?>