Date Range

Do you write posts that have content that should only be available within a certain date range? Maybe you’re writing about a new product where you want a big “This is New!” across the top, but only for a few days. Or you want to mention a coupon that’s only available through the end of the month.

This might just be a plugin for you.

The Date Range plugin adds a shortcode to WordPress that allows you to wrap any content in a post or page and include either a start date, end date, or both. When the content is within the date range it will show. When it’s outside the date range, it won’t.


Once you’ve uploaded and activated the plugin there’s nothing else to do. All options are passed through the shortcode.


This works just like any other shortcode in WordPress. Let’s say you want to say “This is New!” at the top of a post, but only through December 31, 2013. You would insert the following into your post.

[date_range end="2013-12-31"]This is New![/date_range]

Or, you’re introducing a new product and you want the message to start on January 1, 2014. It would look like the following.

[date_range start="2014-01-01"]Here's a message[/date_range]

Your dates can also include times – “2013-12-31 15:00:00” to have it start or expire at 3 in the afternoon. If you leave the time off start times default to 00:00:00 – midnight on the start day – and end times default to 11:59:59 pm – the last second of the day.

See the PHP website for a list of valid date and time formats.

You also have the following attributes that you can with this shortcode for a bit more customization if needed.

  • start: The earliest that the content should show. Defaults to midnight on Jan 1, 1970.
  • end: The latest that the content should show. Defaults to Dec 31, 2037 at 11:59:59 pm
  • before: Message to show in place of content if the start date has not been reached. Defaults to an empty string.
  • after: Message to show in place of content if the current date is past the end date. Defaults to an empty string.
  • unavailable: Message to show in place of content if the date is out of the range between start and end. Defaults to an empty string. Note that this will only show if the before and after attributes are empty. They’ll take priority over this one if both are set.

If you don’t want anything to show outside of the date range you specify, just leave off the before, after, and unavailable attributes.