-
Notifications
You must be signed in to change notification settings - Fork 0
/
board-of-directors.php
150 lines (135 loc) · 5.41 KB
/
board-of-directors.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
<?php
/**
* Template Name: board of directors
*/
get_header(); ?>
<div id="page-overlay">
<main>
<?php the_post(); ?>
<header>
<h1 class="entry-title main"><?php the_title(); ?></h1>
</header>
<br/>
<hr />
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php
$archive_year = date("Y");
if(isset($_GET['archiveyear'])) {
$archive_year = sanitize_text_field($_GET['archiveyear']);
}
$today = date('Ymd');
$upcoming = new WP_Query(array(
'category_name' => 'board-of-directors',
'meta_key' => 'board-info-date',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'board-info-date',
'value' => $today,
'compare' => '>=',
'type' => 'NUMERIC'
)
)
));
?>
<h2>Upcoming Meetings and Agendas</h2>
<?php if ($upcoming->have_posts()) : ?>
<ul class="upcoming-agendas">
<?php while ($upcoming->have_posts()) :
$upcoming->the_post();
$linkText = " ";
//if has field pdf && field description is empty
$pdfText = get_field("agenda-packet-pdf");
if(!empty($post->post_content)) {
$linkText = get_permalink();
} else if ($pdfText != "") {
$linkText = $pdfText;
} else {
$linkText = get_permalink();
}
?>
<li><a href="<?php echo $linkText; ?>">
<?php the_field('board-info-date'); ?> – <?php the_title(); ?>
</a></li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
<? else : ?>
<p>No upcoming events listed.</p>
<?php endif; ?>
<h2><?php echo $archive_year; ?> Past Agendas and Minutes</h2>
<div>
<form method="get" action="">
<label for="archiveyear">Show different year: </label>
<select name="archiveyear" id="archiveyear">
<?php
$cur = date("Y");
$first = 2012;
$range = range($cur, $first);
foreach($range as $r) {
$selected = '';
if ($r == $archive_year) {
$selected = ' selected ';
}
echo '<option value="'.$r.'"'.$selected.'>'.$r.'</option>';
}
?>
</select>
<input type="submit" class="btn" value="Get Meetings">
</form>
</div>
<br />
<?php
$start = $archive_year . '0101';
$end = $archive_year . '1231';
$args = array(
'category_name' => 'board-of-directors',
'meta_key' => 'board-info-date',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'board-info-date',
'value' => $start,
'compare' => '>=',
'type' => 'NUMERIC',
),
array(
'key' => 'board-info-date',
'value' => $end,
'compare' => '<=',
'type' => 'NUMERIC',
),
)
);
$q = new WP_Query($args);
if ( $q->have_posts() ) : ?>
<ul class="past-agendas">
<?php while ($q->have_posts() ) : $q->the_post();
$linkText = " ";
//if has field pdf && field description is empty
$pdfText = get_field("agenda-packet-pdf");
if(!empty($post->post_content)) {
$linkText = get_permalink();
} else if ($pdfText != "") {
$linkText = $pdfText;
} else {
$linkText = get_permalink();
}
?>
<li><a href="<?php echo $linkText; ?>">
<?php the_field('board-info-date'); ?> – <?php the_title(); ?>
</a></li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
<?php else: ?>
<p>No Agendas or Meetings for <?php echo $archive_year; ?></p>
<?php endif; ?>
<?php the_content(); ?>
</div>
</main>
</div> <!-- page-overlay -->
<?php get_footer(); ?>