-
Notifications
You must be signed in to change notification settings - Fork 0
/
category.php
109 lines (93 loc) · 3.78 KB
/
category.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
<?php
get_header();
$categ = get_queried_object();
$taxonomy = $categ->taxonomy;
$term_id = $categ->term_id;
$catcolor = get_field("series_color", $taxonomy . '_' . $term_id);
$catheadimg = get_field("header_image", $taxonomy . '_' . $term_id);
?>
<article class="series-archive" style="background: transparent no-repeat url('<?php echo($catheadimg["url"]); ?>'); background-size:cover;">
<div class="gradient-overlay"></div>
<section class="col-6-12 series-intro">
<h1 class="series-title" style="color:<?php echo($catcolor); ?>;"><?php echo($categ->name); ?></h1>
<p><?php echo($categ->description); ?></p>
</section>
</article>
<article class="series-screenings col-5-12 no-float">
<h1 class="section-title">Upcoming Screenings</h1>
<?php
$filmargs = array(
'post_type' => 'film',
'numberposts'=> -1,
'posts_per_page'=> -1,
'category__in' => array($categ->term_id),
'post_status'=> 'publish'
);
$films = new WP_Query( $filmargs );
if ( $films->have_posts() ) while ( $films->have_posts() ) : $films->the_post();
$agileid = get_post_meta(get_the_ID(), 'agileid')[0];
$prod_countries = explode(",", get_post_meta(get_the_ID(), 'production_country')[0]);
$directors = explode(",", get_post_meta(get_the_ID(), 'director')[0]);
$showargs = array(
'post_type' => 'showing',
'orderby' => 'meta_value',
'meta_key' => 'startdate',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'filmid',
'value' => $agileid,
'compare' => '=',
),
array(
'key' => 'startdate',
'value' => date('n/j/Y h:ia'),
'compare' => '>=',
'type' => 'NUMERIC,'
),
),
'numberposts'=> -1,
'posts_per_page'=> -1,
'post_status'=> 'publish'
);
$shows = new WP_Query( $showargs );
if ( $shows->have_posts() ) {
?>
<section>
<figure>
<img src="<?php the_field('event_image'); ?>" />
<figcaption style="background:<?php echo($catcolor); ?>;">
<h3 class="film-title"><?php the_title(); ?></h3>
<h4 class="film-meta"><?php the_field('year_released'); echo(' / '); echo($prod_countries[0]); if( count($prod_countries) > 1 ) { echo(" +"); } echo(' / '); echo($directors[0]); if( count($directors) > 1 ) { echo(" +"); } ?></h4>
</figcaption>
</figure>
<?php
$dateholder = array();
while ( $shows->have_posts() ) : $shows->the_post();
$dateday = date('l, M j', strtotime(get_field('startdate')));
$datetime = date('h:ia', strtotime(get_field('startdate')));
if( array_key_exists($dateday, $dateholder) ) {
$dateholder[$dateday][$datetime][] = get_field('buylink');
} else {
$dateholder[$dateday] = array();
$dateholder[$dateday][$datetime] = array();
$dateholder[$dateday][$datetime][] = get_field('buylink');
}
endwhile;
$films->reset_postdata();
foreach($dateholder as $date => $time){
echo("<date style='color:".$catcolor.";' class='show-date'>".$date);
foreach($time as $showtime => $buylink) {
echo("<a class='show-time' href='".$buylink[0]."'>".$showtime."</a>");
}
echo("</date>");
}
?>
<?php the_content(); ?>
</section>
<?php
}
endwhile;
?>
</article>