Adding countdown to your theme using php

countdown_using_php

For theme designers sometimes #php is better than #shortcodes. So here i will show you how to easily add countdown widget to your theme file. You need to know some php to integrate it with your posts.

Just open appropriate template file and add this simple code:

<div class="countdown-container" style="width:250px; margin:0 auto;">
<?php
if(function_exists('shailan_CountdownWidget_shortcode')){
  $countdown = array(
	'title'		=> '',
	'event'		=> 'Event description here',
	'date'		=> '12 March 2011',
	'hour'		=> 16,
	'minutes'	=> 45,
	'seconds'	=> 0,
	'format'	=> 'yowdHMS',
	'link'		=> false, // set true to remove link, false to support me
  ); 

  echo shailan_CountdownWidget_shortcode($countdown);
}
?>
</div>

Change date, event title and format as needed.

And you are done.

date attribute here is really clever, it uses strtotime which can convert many string formats to date. You can easily integrate date using any of the formats supported. Read more about strtotime.

If you find this plugin useful consider donating a few bucks. Thanks.

Enjoy.

5 thoughts on “Adding countdown to your theme using php”

  1. I’ve tried the above code without success. The plugin is activated and the code added to the theme. Am I missing some steps?

Comments are closed.