How to add a countdown to your post using shortcode

I added shortcode functionality to the wordpress countdown widget with version 2.4. Using this new update, you can add countdown timers to your posts and pages so easily. Here is how to use the shortcode.

Basic syntax

Basic shortcode syntax:

[countdown event="Testing shortcode" date="12 June"]

This shortcode displays:

Default syntax

Let’s add hours & minutes to this:

[countdown event="Event with hour & minutes" date="12 June" hour="18" minutes="54"] :

Please note that, Hours is 24 based. If you write 6pm there, it won’t work.

Shortcode attributes

Here is a list of default shortcode attributes:

$args = shortcode_atts(array(
	'title'=>'',
	'event'=>'',
	'date'=>false,
	'month'=>'',
	'day'=>'',
	'hour'=>'0',
	'minutes'=>'0',
	'seconds'=>'0',
	'year'=>'',
	'format'=>'yowdHMS',
	'link'=>false
), $atts );

Note that if you use date, you don’t need to specify day, month and year. Those are automatically cast via magic date attribute.

Full syntax

And here is the full shortcode template in case you need it:

[countdown title="Countdown" event="Until next release" date="17 June" hour="13" minutes="45" seconds="00" format="DHMS"]

Countdown

For shortcode displays you can’t define background color and color values. Those can only be changed via CSS. For styling tips read my tutorial here.

I hope you find this useful. Any thoughts?



NS Weight Release