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.
If you don’t want anything to show outside of the date range you specify, just leave off the before, after, and unavailable attributes.