-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-music.php
68 lines (60 loc) · 2.07 KB
/
page-music.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
<?php
get_header();
?>
<article class="p-section primary entry">
<h2 class="post-title fname">
<?php the_title(); ?>
</h2>
<?= component('edit_button') ?>
<section>
<?php
// Get concerts with valid embed links in their programmes
$concerts = event_query(array(
'post_type' => 'concert',
'has_av' => true
));
?>
<ul>
<?php
$lastyear = INF;
$lastindex = array_keys($concerts)[count($concerts) - 1];
$media_items = array();
foreach ($concerts as $index => $post) {
$concdt = DateTime::createFromFormat('d/m/Y', get_field('dtstart'));
$concyr = $concdt->format('Y');
$next = $index + 1;
$nextconc = isset($concerts[$next]) ? $concerts[$next] : NULL;
$nextconcdt = $nextconc ? DateTime::createFromFormat('d/m/Y', get_field('dtstart', $nextconc->ID)) : NULL;
$nextconcyr = $nextconcdt ? $nextconcdt->format('Y') : NULL;
$performer_link =
'<a href="' . get_the_permalink() . '">' .
get_the_title() .
'</a>';
while (have_rows('programme')) {
the_row();
$media_item = component('embed_card', array(
'post' => $post
));
if ($media_item) {
$media_items[] = $media_item;
}
}
if ($concyr < $lastyear) {
echo '<li>
<h3 class="h2">' . $concyr . '</h3>';
}
if ($concyr !== $nextconcyr) {
echo component('responsive_card_list', array('cards' => $media_items));
echo '</li>';
$media_items = array();
}
$lastyear = $concyr;
} ?>
</ul>
</li>
</ul>
</section>
</article>
<?php
get_footer();
?>