From Dan, 10 Years ago, written in Plain Text.
This paste is a reply to sort custom posts by custom meta value data from Dan - view diff
Embed
  1. while ($sunday_query->have_posts()) : $sunday_query->the_post();
  2.        
  3.         $sort_array = array();
  4.         $schedules = get_post_meta($post->ID, 'show_sched', false);
  5.         $title = get_the_title();
  6.  
  7.         foreach($schedules as $schedule):
  8.  
  9.                 $theday = $schedule[0]['day'];
  10.                 $theorder = $schedule[0]['start_hour'];
  11.  
  12.                 foreach($schedule as $key => $value):
  13.  
  14.                         $sort_array[$theorder] = $schedule;
  15.  
  16.                 endforeach;
  17.  
  18.     endforeach;
  19.  
  20.         ksort($sort_array, SORT_NUMERIC);
  21.  
  22.         foreach($sort_array as $sort):
  23.                 foreach($sort as $key => $value):
  24.                         $day = $value['day'];
  25.                         $order = $value['start_hour'];
  26.                         if($day == 'Sunday'):
  27.                                 echo $day.', '.$order.', '.$title;
  28.                                 echo '<br>';
  29.                         endif;
  30.                 endforeach;
  31.         endforeach;
  32.  
  33. endwhile;