2 回答
TA贡献1868条经验 获得超4个赞
function todays_content(){
$date = date('l');
switch ($date) {
case 'Sunday': $content = do_shortcode('[sunday_content]'); break;
case 'Monday': $content = do_shortcode('[monday_content]'); break;
case 'Tuesday': $content = do_shortcode('[tuesday_content]'); break;
case 'Wednesday': $content = do_shortcode('[wednesday_content]'); break;
case 'Thursday': $content = do_shortcode('[thursday_content]'); break;
case 'Friday': $content = do_shortcode('[friday_content]'); break;
case 'Saturday': $content = do_shortcode('[saturday_content]'); break;
}
return '<div class="daily_contant">'.$content.'</div>';
}
add_shortcode( 'show_today_content', 'todays_content' );
TA贡献1862条经验 获得超7个赞
在这种情况下没有必要使用开关 :) 。你应该返回而不是回应它
function todays_content(){
$today = date('l');
return "Today is {$today}";
}
add_shortcode( 'show-today-content', 'todays_content' );
用法:
[show-today-content]
- 2 回答
- 0 关注
- 166 浏览
添加回答
举报