Skip to content

Instantly share code, notes, and snippets.

@carstingaxion
Created July 8, 2012 12:21
Show Gist options
  • Save carstingaxion/3070690 to your computer and use it in GitHub Desktop.
Save carstingaxion/3070690 to your computer and use it in GitHub Desktop.
Countdown Shortcode for WordPress
<?php
function countdown_shortcode ( $atts ) {
extract( shortcode_atts( array(
'date' => '',
), $atts ) );
if ( !isset($date) )
return false;
return '<span class="countdown">'.floor( ( strtotime( $date ) - time() )/60/60/24 ).'</span>';
}
add_shortcode( 'countdown', 'countdown_shortcode' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment