主题目录 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]
声明:本站所有文章,如无特殊说明或标注,均为本站转载发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。