$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 '
';
//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 '