For WordPress Theme Designers sometimes PHP is better than shortcodes. So in this post, I will show you how to add countdown widget to your theme using PHP code. In order to use this method, you need to know some basic PHP editing and have a beginner level WordPress theme editing experience.
Just open appropriate template file (page.php, single.php etc.) 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
Change date, event title, and format as needed.
date attribute here is really clever, it uses strtotime PHP function which can convert many string formats to date. You can easily integrate date using any of the formats supported. Read more about strtotime here.
If you find this plugin useful consider donating a few bucks. Thanks.