-
Notifications
You must be signed in to change notification settings - Fork 0
/
films-upcoming.php
73 lines (56 loc) · 1.93 KB
/
films-upcoming.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
<?php
/*
Template Name: Upcoming Films
*/
get_header();
$container = get_theme_mod( 'understrap_container_type' );
?>
<div class="content-layout no-sidebar">
<main class="site-main <?php echo esc_attr( $container ); ?>">
<?php
while ( have_posts() ) :
the_post();
the_title( '<h1 class="entry-title">', '</h1>' );
the_content();
endwhile;
// Setting the time zone is not helpful, as it the time as though it is GMT.
// date_default_timezone_set('America/Los_Angeles');
$right_now = date('m/j/Y h:i a', time());
$today_unix = strtotime('today midnight');
$today = date('m/j/Y h:i a', $today_unix);
$i=1;
$the_friday = $today_unix;
while($i<=7) {
$the_friday = strtotime('-1 day', $the_friday);
if ( date('l', $the_friday) == 'Friday' ) :
break;
endif;
$i++;
}
if ( date('l', $today_unix) == 'Friday' ) :
$the_friday = $today_unix;
endif;
$the_friday_date = date('m/j/Y h:i a', $the_friday);
$n = 1;
while ($n <= 52):
$the_thursday = strtotime('+6 days', $the_friday);
$disp_friday = date('n/j', $the_friday);
$disp_thursday = date('n/j', $the_thursday);
$films_this_week = do_shortcode('[film_teasers list_only="1" from_date="' . $the_friday .'" to_date="' . $the_thursday .'"]');
$films_this_week_arr = explode(',',$films_this_week);
if (!empty($films_this_week)) :
echo '<div class="week">';
echo '<h4 class="week-title">Week of ' . $disp_friday . ' - ' . $disp_thursday . '</h4>';
echo do_shortcode('[film_teasers list_only="0" from_date="' . $the_friday .'" to_date="' . $the_thursday .'"]');
echo '</div>';
$the_friday = strtotime('+7 days', $the_friday);
if ( $the_friday > strtotime($GLOBALS['last_screening_date'])) :
break;
endif;
endif;
$n++;
endwhile;
?>
</main>
</div>
<?php get_footer(); ?>