-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsidebar.php
More file actions
150 lines (108 loc) · 3.03 KB
/
sidebar.php
File metadata and controls
150 lines (108 loc) · 3.03 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
// dynamic_sidebar('sidebar-primary');
// display grandparent page title
// $grandparent = get_post(top_parent());
?>
<?php
global $post;
$depth = count(get_ancestors($post->ID, 'post'));
$parent = $post->post_parent;
$grandparent = get_post($parent);
$location = ($depth == 3) ? $grandparent->post_parent : $parent;
if ($location != top_parent() || stristr($post->post_title, "specials")) { ?>
<h1><?php echo get_the_title($location); ?></h1>
<nav id="nav-subsection">
<ul>
<?php
global $post;
$template = 'page-featured.php';
$Pages = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = '$template'");
foreach($Pages as $featured) {
$exclude_featured .= $featured . ',';
}
$args = array(
'child_of' => $location,
'parent' => $location,
'sort_column' => 'menu_order',
'exclude' => $exclude_featured
);
$pages = get_pages( $args );
foreach ( $pages as $page ) {
if ( $post->ID == $page->ID ) {
echo '<li class="current_page_item">';
} else {
echo '<li>';
}
$url = get_permalink( $page->ID );
$children = get_pages('child_of='.$page->ID);
//check for child pages
if ( $children ) {
echo '<a href="" class="no-pjax has_drop">'.$page->post_title.'</a>';
//spit out dropdown menu
echo '<ul class="dropdown">';
foreach ($children as $child) {
$childurl = get_permalink( $child->ID );
if ( $post->ID == $child->ID ) {
echo '<li class="current_page_item">';
} else {
echo '<li>';
}
echo '<a href="'.$childurl.'">'.$child->post_title.'</a></li>';
}
echo '</ul>';
} else {
echo '<a href="'.$url.'">'.$page->post_title.'</a>';
}
echo '</li>';
}
?>
</ul>
<?php //extra files ?>
<?php
$files = get_field('related-files', $location);
if ($files) { ?>
<ul class="tertiary">
<?php
wp_list_pages ( array(
'child_of' => $location,
'title_li' => '',
'sort_column' => 'menu_order',
'meta_key' => '_wp_page_template',
'meta_value' => 'page-featured.php'
));
?>
<?php foreach ($files as $file) {
$title = $file['title'];
$src = $file['url'];
echo '<li><a href="'.$src.'" target="_blank" class="no-pjax">'.$title.'</a></li>';
} ?>
</ul>
<?php } ?>
</nav>
<?php }
// if this is a contact page, show the contact sidebar
if (stristr($post->post_title, "contact")) { ?>
<h1><?php echo get_the_title($post->post_ID); ?></h1>
<?php dynamic_sidebar('sidebar-contact');
}
if ( is_home() || is_single() || is_category() || is_archive() ) { ?>
<!-- <h1><?php //echo get_the_title($post->post_parent); ?></h1> -->
<nav id="nav-subsection">
<h1>What's New</h1>
<ul>
<?php
global $post;
wp_list_categories ( array(
'depth' => 1,
'hide_empty' => 0,
'title_li' => ''
));
?>
</ul>
<hr />
<h1>Archives</h1>
<ul>
<?php wp_get_archives('type=yearly'); ?>
</ul>
</nav>
<?php } ?>