Skip to content

Instantly share code, notes, and snippets.

@INDIAN2020
Created February 8, 2013 01:10
Show Gist options
  • Save INDIAN2020/4735751 to your computer and use it in GitHub Desktop.
Save INDIAN2020/4735751 to your computer and use it in GitHub Desktop.
display content after specified date
/*
Countdown timer shortcode, display content after specified date
use this : [cdt month="10" day="17" year="2011"]
This is content that will only be shown after a set number of days.
*/
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=\"event\">Just <b>($remain)</b> days until content is available</div>";
}else if($remain == 1 ){
return $daysremain = "<div class=\"event\">Just <b>($remain)</b> day until content is available</div>";
}else{
return $content;
}
}
add_shortcode('cdt', 'content_countdown');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment