trms / wp-cablecast

A Wordpress plugin for Cablecast
GNU General Public License v3.0
2 stars 6 forks source link

Display schedule for a specific show #5

Open bryanharley opened 7 years ago

bryanharley commented 7 years ago

How can I display when and on what channels a specific show is scheduled? I looked at cablecast_get_schedules, but I don't think I can do it with that function.

bryanharley commented 5 years ago

Think I figured this out by creating a new function that searches the schedule by show_id

Put this in theme_functions.php or functions.php

function cablecast_get_show_schedule($show_id) { global $wpdb; $table = $wpdb->prefix . 'cablecast_schedule_items'; return $wpdb->get_results($wpdb->prepare("SELECT * FROM $table WHERE show_id=%d AND run_date_time >= CURDATE()", $show_id )); }

Put this in your own theme file or modify display.php

$get_show_id = get_post_meta($post->ID, 'cablecast_show_id', true);

$schedule_items = cablecast_get_show_schedule($get_show_id);

if(!isset($schedule_items) || $schedule_items == NULL) {
$schedule = array();
} else {
$schedule = is_array($schedule_items) ? $schedule_items : array($scheduleitems);
}
if (count($schedule) == 0) { echo "\n"; } else {
echo "Airing"; foreach($schedule as $item) { $DateTime = date('l, F j - g:ia', strtotime($item->run_date_time)); echo $DateTime; echo " on ".$item->channel_id."
"; } }