我有一个wordpress网站。我需要在新闻时段展示DIV。所以我在模板函数中有一个函数。它看起来是这样的:
function kiroj_live_news() {
$week_day = date('w');
$current_time = date('Hi');
$show_news_div = false;
if ($week_day >= 1 && $week_day <= 5)
{
if (($current_time >= '0430' && $current_time <= '0800') || ($current_time >= '1200' && $current_time <= '1300') || ($current_time >= '1700' && $current_time <= '1830') || ($current_time >= '2300' && $current_time <= '2330'))
{
$show_news_div = true;
}
}
if ($week_day == 6)
{
if (($current_time >= '0700' && $current_time <= '0830') || ($current_time >= '1700' && $current_time <= '1800') || ($current_time >= '1830' && $current_time <= '1900') || ($current_time >= '2300' && $current_time <= '2330'))
{
$show_news_div = true;
}
}
if ($week_day == 0)
{
if (($current_time >= '0600' && $current_time <= '0700') || ($current_time >= '1700' && $current_time <= '1800') || ($current_time >= '1830' && $current_time <= '1900') || ($current_time >= '2300' && $current_time <= '2359'))
{
$show_news_div = true;
}
}
}在我想要显示我的DIV的区域,我有一个if:
<?php
$display = kiroj_live_news ();
if ($display)
{
?>
<div class="live-news"><a href="http://www.kirotv.com/videos/news/kiro-newscast-hd2/vCYwYn/" target="_blank">Breaking News</a></div>
<?php
}
?>我已经更改了主函数中的时间,尝试了PHP手册(http://php.net/manual/en/function.date.php)中的其他日期()格式,但无法显示DIV值。有人能帮上忙吗?
发布于 2015-05-09 00:56:16
function kiroj_live_news() {
//your code here
....
return $show_news_div;
}
$display = kiroj_live_news();
......您的函数不返回任何内容-因此它始终为FALSE。
https://stackoverflow.com/questions/30129034
复制相似问题