主题目录 functions.php 内插入以下代码
function content_countdown($atts, $content = null){
extract(shortcode_atts(array(
'month' => '',
'day' => '',
'year' => ''
), $atts));
$remain = ceil((mktime( 0,0,0,(int)$month,(int)$day,(int)$year) - time())/86400);
if( $remain > 1 ){
return $daysremain = "<div class="alert alert-success"><center>本篇文章内容在<b>($remain)</b>天后可见,请持续关注本站~</center></div>";
}else if($remain == 1 ){
return $daysremain = "<div class="alert alert-info">本篇文章内容在<b>($remain)</b>天后可见,请持续关注本站~</div>";
}else{
return $content;
}
}
add_shortcode('ccdt', 'content_countdown');
文章内插入
[ccdt month=”12″ day=”20″ year=”2020″]本次活动已过期,请下次再来哦![/ccdt]