Adding countdown to your theme 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;">
  $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);

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.


About Staff is a design blog about WordPress and web design. We usually write about wordpress, plugins, themes, web design resources, php, css, jquery, adsense and more.. If you want to get notified about our posts, be sure to subscribe to our feed or follow us on facebook. You can also subscribe to our mailing list. No spam, we promise.

5 Comments on Adding countdown to your theme using php

  1. // July 30, 2011 at 8:33 am // Reply

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

  2. Good stuff! Just what I was looking for. ;)

  3. Web designing course in Chandigarh // March 17, 2011 at 11:58 am // Reply

    Awesome post! It really helped me a lot! Thanks for sharing it.

Leave a comment

Your email address will not be published.