'broadcast', 'numberposts' => -1 ); //$broadcast = new WP_Query($broadcast_post); $broadcast = get_posts($broadcast_post); $palinsesto = []; //foreach ($broadcast->posts as $post) { foreach ($broadcast as $post) { $on_air_day = $on_air_start = $on_air_end = []; for ($d=0;$d<7;$d++) { $on_air_day[] = get_post_meta($post->ID, 'on_air_day_'.$d, false); $on_air_start[] = get_post_meta($post->ID, 'on_air_start_'.$d, false); $on_air_end[] = get_post_meta($post->ID, 'on_air_end_'.$d, false); if (!empty($on_air_day[$d][0])&&!empty($on_air_start[$d][0])&&!empty($on_air_end[$d][0])) { $palinsesto[$on_air_day[$d][0]][(string) $on_air_start[$d][0]] = array( 'ID' => $post->ID, 'start' => $on_air_start[$d][0], 'end' => $on_air_end[$d][0], 'on_air' => true, 'title' => $post->post_title, 'excerpt' => $post->post_excerpt, 'thumb_url' => get_the_post_thumbnail_url($post->ID, 'full'), 'the_permalink' => get_permalink($post->ID), ); } } $rerun_day = $rerun_start = $rerun_end = []; for ($d=0;$d<7;$d++) { $rerun_day[] = get_post_meta($post->ID, 'rerun_day_'.$d, false); $rerun_start[] = get_post_meta($post->ID, 'rerun_start_'.$d, false); $rerun_end[] = get_post_meta($post->ID, 'rerun_end_'.$d, false); if (!empty($rerun_day[$d][0])&&!empty($rerun_start[$d][0])&&!empty($rerun_end[$d][0])) { $palinsesto[$rerun_day[$d][0]][(string) $rerun_start[$d][0]] = array( 'ID' => $post->ID, 'start' => $rerun_start[$d][0], 'end' => $rerun_end[$d][0], 'on_air' => false, 'title' => $post->post_title, 'excerpt' => $post->post_excerpt, 'thumb_url' => get_the_post_thumbnail_url($post->ID, 'full'), 'the_permalink' => get_permalink($post->ID), ); } } } ksort($palinsesto); /*echo '
';
    print_r($palinsesto);
    echo '
';*/ $today = date("N"); for ($x=1;$x<=7;$x++) { /*echo '
';
    echo("$today,$x");
    echo '
';*/ if ($x == $today) $tabs .= "
  • ".$week_days[$x-1]."
  • "; else $tabs .= "
  • ".$week_days[$x-1]."
  • "; $content .= '
  • '; if (!empty($palinsesto[$x])) { ksort($palinsesto[$x]); foreach ($palinsesto[$x] as $key => $broadcast) { $content .= '
    '; //$content .= '

    '.$broadcast['thumb_url'].'

    '; $content .= ''; /* $content .= ''.$broadcast['title'].''; */ $content .= '

    '.$broadcast['title'].'

    '; $content .= '
    '; /* Indico sotto al titolo se la trasmissione รจ una replica o una diretta */ $content .= (!$broadcast['on_air']) ? "[replica]" : "[diretta]"; $content .= '

    '.$broadcast['start'].' - '.$broadcast['end'].'

    '; $content .= '

    '.$broadcast['excerpt'].'

    '; //$content .= '

    '.$broadcast['the_permalink'].'

    '; $content .= "
    "; } } $content .= '
  • '; } ?>