-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-timetable.php
226 lines (165 loc) · 5.18 KB
/
single-timetable.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?php
/*
Template Name: route_individual_page
*/
get_header(); ?>
<?php get_template_part( 'route-header'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$parent_id = -1;
// get the parent route by shared class
get_field( 'shared_class', $post_id );
$args = array(
'numberposts' => -1,
'post_type' => 'route',
'meta_key' => 'shared_class',
'meta_value' => get_field( 'shared_class')
);
// get results
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ):
while ( $the_query->have_posts() ) : $the_query->the_post();
$parent_id = $post->ID;
endwhile;
endif;
wp_reset_query();
?>
<h1 id="route-page-title" class="over-blue"><i id="icon-lrg-<?php the_field('shared_class'); ?>" class="route-icon"></i><?php echo get_the_title($parent_id) ?>
<?php
echo " - ";
if (strpos(get_the_title(),'_') !== false) {
echo ucwords(explode('_',get_the_title())[1]);
} else {
echo "Timetable";
}
?>
</h1>
<div id="route-select-container">
<?php
wp_reset_query();
$query = new WP_Query(array(
'posts_per_page' => -1,
"post_type"=>"route",
'meta_key' => 'route_number',
'orderby' => 'meta_value',
'order' => 'ASC'
));
if ( $query->have_posts() ) {
?>
<select id="routes-dropdown" onchange="location = this.options[this.selectedIndex].value;">
<option value="#">View a different route</option>
<?php
while ( $query->have_posts() ) {
$query->the_post();
?>
<option value="<?php echo explode('_',get_field('shared_class'))[1]; ?>"><?php the_field('route_number'); echo " - "; the_title(); ?></option>
<?php
}
?>
</select>
<?php
}
wp_reset_postdata();
?>
</div><!-- end #route-select-container -->
<br />
<div id="timetable-return-link"><a href="<?php echo get_the_permalink($parent_id) ?>"><< Back to <?php echo get_the_title($parent_id); ?> Route Page</a></div>
<div id="generic-wide-container">
<?php
$saved_id = $post->ID;
// get the parent route by shared class
get_field( 'shared_class', $post_id );
$args = array(
'numberposts' => -1,
'post_type' => 'timetable',
'meta_key' => 'shared_class',
'meta_value' => get_field( 'shared_class')
);
// get results
$the_query = new WP_Query( $args );
if(sizeof($the_query->posts) > 1) {
if( $the_query->have_posts() ):
?>
<div id="other-timetables">
<?php
echo "<h3>Other Timetables for this Route</h3><ul>";
while ( $the_query->have_posts() ) : $the_query->the_post();
if($saved_id !== $post->ID) {
$title_length = sizeof(explode('_',get_the_title()));
?>
<li><a href="<?php echo get_the_permalink(); ?>"><?php echo ucwords(str_replace('-',' - ',str_replace('_',', ',get_the_title() ) )); ?></a></li>
<?php
}
endwhile;
?>
</ul>
<?php
endif;
?>
</div><!-- end #other-timetables -->
<?php
} else {
?>
<br />
<?php
}
wp_reset_query();
?>
<?php
?>
<div id="timetable-content" class="timetable-left-marg">
<?php the_content(); ?>
</div><!-- end #timetable-content -->
<br style="clear: both;" />
<?php endwhile; else : ?>
<article id="post-not-found" class="hentry cf">
<header class="article-header">
<h1><?php _e( 'Oops, Post Not Found!', 'bonestheme' ); ?></h1>
</header>
<section class="entry-content">
<p><?php _e( 'Uh Oh. Something is missing. Try double checking things.', 'bonestheme' ); ?></p>
</section>
<footer class="article-footer">
<p><?php _e( 'This is the error message in the page.php template.', 'bonestheme' ); ?></p>
</footer>
</article>
<?php endif; ?>
<div id="timetable-detail-maps">
<h2>Route Detail Maps (Click to expand)</h2>
<?
$savedRoute = get_field('route_number',$parent_id);
$args = array(
'post_type' => 'attachment',
'post_mime_type' =>'image',
'post_status' => 'inherit',
'posts_per_page' => -1,
'meta_key' => 'route_number',
//'meta_value' => get_field('route_number')
);
// get results
$the_query = new WP_Query( $args );
// The Loop
?>
<?php if( $the_query->have_posts() ): ?>
<ul>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php
if (strpos(get_field('route_number'),$savedRoute) !== false) {
?>
<li class="route-detail-holder">
<span class="min"></span>
<a class="minimized" href="<?php echo wp_get_attachment_image_src( $attachment_id, 'large' )[0]; ?>"><img class="sml" src="<?php echo wp_get_attachment_thumb_url( $post->ID ); ?>" /></a>
</li>
<?php
}?>
<?php endwhile; ?>
</ul>
<br style="clear: both;" />
<?php endif; ?>
<?php wp_reset_query();
?>
</div><!- end #timetable-detail-maps -->
</div><!-- end #generic-wide-container -->
<?php get_template_part( 'generic-page-bottom'); ?>
<?php get_footer();
?>