- $days = array();
- $days['sunday'] = array();
- $days['monday'] = array();
- $days['tuesday'] = array();
- $days['wednesday'] = array();
- $days['thursday'] = array();
- $days['friday'] = array();
- $days['saturday'] = array();
- // initialization for $inner_args & backup the current global $post
- $sunday_args = array(
- 'post_type' => 'show',
- 'posts_per_page' => '-1'
- );
- $sunday_query = new WP_Query($sunday_args);
- echo '<ul class="show_list">';
- while ($sunday_query->have_posts()) : $sunday_query->the_post();
- $temp_array = array();
- $schedules = get_post_meta($post->ID, 'show_sched', false);
- $title = get_the_title();
- if($title == 'Dan Test') {
- //echo '<pre>';
- //var_dump($schedules); exit;
- }
- foreach($schedules as $s):
- foreach($s as $schedule):
- $temp_array = array();
- $theday = $schedule['day'];
- $theorder = $schedule['start_hour'];
- $themeridian = $schedule['start_meridian'];
- if(!empty($themeridian) && strtolower($themeridian == 'pm')) {
- $theorder += 12; // $theorder equals $theorder + 12
- }
- $temp_array['title'] = $title;
- $temp_array['link'] = get_the_permalink();
- $temp_array['day'] = $theday;
- $temp_array['order'] = $theorder;
- $days[strtolower($theday)][$theorder] = $temp_array;
- endforeach;
- endforeach;
- endwhile;
- foreach($days as $day) {
- ksort($day);
- foreach($day as $d) {
- $theday = $d['day'];
- $theorder = $d['order'];
- $title = $d['title'];
- if($theday == 'Sunday') {
- echo '<li class="show">';
- echo '<span>'.$theorder.'</span>';
- echo '<div>'.$title.'</div>';
- echo '</li>';
- } elseif($theday == 'Monday') {
- echo '<li class="show">';
- echo '<span>'.$theorder.'</span>';
- echo '<div>'.$title.'</div>';
- echo '</li>';
- } elseif($theday == 'Tuesday') {
- echo '<li class="show">';
- echo '<span>'.$theorder.'</span>';
- echo '<div>'.$title.'</div>';
- echo '</li>';
- } elseif($theday == 'Wednesday') {
- echo '<li class="show">';
- echo '<span>'.$theorder.'</span>';
- echo '<div>'.$title.'</div>';
- echo '</li>';
- } elseif($theday == 'Thursday') {
- echo '<li class="show">';
- echo '<span>'.$theorder.'</span>';
- echo '<div>'.$title.'</div>';
- echo '</li>';
- } elseif($theday == 'Friday') {
- echo '<li class="show">';
- echo '<span>'.$theorder.'</span>';
- echo '<div>'.$title.'</div>';
- echo '</li>';
- } elseif($theday == 'Saturday') {
- echo '<li class="show">';
- echo '<span>'.$theorder.'</span>';
- echo '<div>'.$title.'</div>';
- echo '</li>';
- } else {}
- }
- }
- echo '</ul>';
Stikked
