How would I go about editing this code for displaying a random post from a category for 24 hours, then switching to another random post? This would be to show a Tip of the Day.
if ( ! function_exists( 'cb_breaking_news' ) ) {
function cb_breaking_news(){
$cb_breaking_filter = ot_get_option('cb_breaking_news_filter', NULL);
if ($cb_breaking_filter == NULL) { $cb_breaking_cat = implode(",", get_all_category_ids()); } else { $cb_breaking_cat = implode(",", $cb_breaking_filter); }
$cb_breaking_args = array( 'post_type' => 'post', 'numberposts' => '6', 'category' => $cb_breaking_cat, 'orderby' => 'rand', 'post_status' => 'publish', 'suppress_filters' => false);
$cb_news_posts = wp_get_recent_posts( $cb_breaking_args);
$cb_news = NULL;
$cb_news .= '<div class="cb-breaking-news"><span>'. __("Tip of the Day", "cubell") .' <i class="icon-long-arrow-right"></i></span><ul>';
foreach( $cb_news_posts as $news ) {
$cb_news .= '<li><a href="' . get_permalink($news["ID"]) . '" title="Look '.esc_attr($news["post_title"]).'" >' . $news["post_title"].'</a> </li> ';
}
$cb_news .= '</ul></div>';
return $cb_news;
}
}
I found some code about it online although, I can't seem to get it to work with this. The webpage just goes blank.