From Dan, 10 Years ago, written in Plain Text.
Embed
  1. <?php
  2. /**
  3.  * The template for displaying all pages.
  4.  *
  5.  * This is the template that displays all pages by default.
  6.  * Please note that this is the WordPress construct of pages
  7.  * and that other 'pages' on your WordPress site will use a
  8.  * different template.
  9.  *
  10.  * @package _tk
  11.  */
  12.  
  13. get_header(); ?>
  14.  
  15.         <?php while ( have_posts() ) : the_post(); ?>
  16.  
  17.         <?php do_shortcode('[master-schedule]'); ?>
  18.  
  19.                 <?php // get_template_part( 'content', 'page' ); ?>
  20.  
  21.                 <?php // echo do_shortcode('[list-shows]') ?>
  22.  
  23.                 <?php
  24.  
  25.                         wp_reset_query();
  26.  
  27.                         // get today's date
  28.                         $today = date('Y-m-j');
  29.  
  30.                         // what week of the month does today's date fall within - single integer (1-5)
  31.                         $currentweek = getWeeks($today, "sunday");
  32.                         echo $currentweek;
  33.  
  34.                         $args = array(
  35.                             'post_type' => 'show',
  36.                             'posts_per_page' => '-1',
  37.                         );
  38.  
  39.                         query_posts( $args ); ?>
  40.  
  41.                         <div id="station-show-list">
  42.  
  43.                                 <ul>
  44.  
  45.                         <?php while ( have_posts() ) : the_post();
  46.  
  47.                                 // the show date
  48.                                 $schedule = get_post_meta($post->ID, 'show_sched', true);
  49.                                 $theday = $schedule[0]['day'];
  50.  
  51.                                 // the show week
  52.                                 $week = get_field('show_frequency');
  53.                                 $firstrun = $week[0];
  54.                                 $secondrun = $week[1];
  55.  
  56.                                 if($firstrun == $currentweek) {
  57.  
  58.                                         echo '<li>';
  59.                                                 echo '<h2>Monday</h2>';
  60.                                                 if($theday == 'Monday') {
  61.                                                         echo the_title();
  62.                                                 }
  63.                                         echo '</li>';
  64.  
  65.                                         echo '<li>';
  66.                                                 echo '<h2>Tuesday</h2>';
  67.                                                 if($theday == 'Tuesday') {
  68.                                                         echo the_title();
  69.                                                 }
  70.                                         echo '</li>';
  71.  
  72.                                         echo '<li>';
  73.                                                 echo '<h2>Wednesday</h2>';
  74.                                                 if($theday == 'Wednesday') {
  75.                                                         echo the_title();
  76.                                                 }
  77.                                         echo '</li>';
  78.  
  79.                                         echo '<li>';
  80.                                                 echo '<h2>Thursday</h2>';
  81.                                                 if($theday == 'Thursday') {
  82.                                                         echo the_title();
  83.                                                 }
  84.                                         echo '</li>';
  85.  
  86.                                         echo '<li>';
  87.                                                 echo '<h2>Friday</h2>';
  88.                                                 if($theday == 'Friday') {
  89.                                                         echo the_title();
  90.                                                 }
  91.                                         echo '</li>';
  92.  
  93.                                         echo '<li>';
  94.                                                 echo '<h2>Saturday</h2>';
  95.                                                 if($theday == 'Saturday') {
  96.                                                         echo the_title();
  97.                                                 }
  98.                                         echo '</li>';
  99.  
  100.                                         echo '<li>';
  101.                                                 echo '<h2>Sunday</h2>';
  102.                                                 if($theday == 'Sunday') {
  103.                                                         echo the_title();
  104.                                                 }
  105.                                         echo '</li>';
  106.  
  107.                                 } elseif ($secondrun == $currentweek) {
  108.  
  109.                                 } else {
  110.                                         echo '<div>';
  111.                                         echo the_title();
  112.                                         echo '</div>';
  113.                                 }
  114.  
  115.                         endwhile; // end of the loop.
  116.  
  117.                         echo '</ul></div>';
  118.  
  119.                 wp_reset_query(); ?>
  120.  
  121.         <?php endwhile; // end of the loop. ?>
  122.  
  123. <?php // get_sidebar(); ?>
  124. <?php get_footer(); ?>
  125.