文章目录
本文最后更新于 2022-10-14,已超过 365 天未更新,内容可能已失效。

主题目录 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=”2019″]本次活动已过期,请下次再来哦![/ccdt]

总结

通过以上方法,如果你学会了,快点部署到自己的WordPress网站上吧,最后别忘记收藏,分享本站哦。

CC 许可协议
署名-非商业性使用-相同方式共享 4.0 国际 了解协议
文章链接:https://zptheme.com/2539.html
本文作者:子佩·来源:子佩工作室

除非注明,子佩工作室 文章均为原创,转载请以链接形式标明本文地址。

相关推荐

登录后即可发表评论

社交账号登录

全部评论 (0)