countdown_using_php

Adding countdown to your theme using php

on March 2, 2011 | 2,574 views

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.

About Shailan.com Staff

Shailan.com is a design blog about WordPress and web design. We regularly 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.

Share Your Thoughts

Your email address will not be published.


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

  1. rrs@reinar-svendsen.dk says:

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

    1. Metin Saylan says:

      could you send me a link to your site.

  2. Azhar Kamar says:

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

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