Simple Timed Content
Adds a shortcode and function allowing you to force the contents of a post or page to appear or expire after a specific date, day and/or time.
Description
After installation, simply use the shortcode [timed] around any post or page contents that you wish to appear or expire on a specific date and/or time.
Six parameters can be used - ondate, offdate, ontime, offtime, onday and offday.
ondate : Date after which you wish the content to appear, in format YYYYMMDD.
offdate : Date after which you wish the content to expire, in format YYYYMMDD.
ontime : Time after which you wish the content to appear, in format HHMM.
offtime : Time after which you wish the content to expire, in format HHMM.
onday : Day on which you wish the content to appear - 1 (for Monday) through 7 (for Sunday)
offday : Day on which you wish the content to expire - 1 (for Monday) through 7 (for Sunday)
If any of these aren't specified then a logical alternative is found - e.g. not specifying ondate or ontime means the text will appear immediately (until the conditions of any expiry date/time is met).
Here's some examples of use..
[timed offdate="20102412"]It's nearly Christmas![/timed]
This will cause the message to disappear after the 24th December 2010.
[timed ondate="20100101" offdate="20101231"]It's 2010[/timed]
This will cause the message to only appear during the year 2010.
[timed ondate="20100101" offdate="20101231" ontime="0800" offtime="1200"]It's between 8am and midday[/timed]
This will cause the message to appear between 8am and midday during the year 2010.
[timed onday="1" offday="3"]It's Monday to Wednesday[/timed]
This will cause the message to only appear Monday, Tuesday and Wednesday.
Function Call
If you wish to use this facility elsewhere in your theme - e.g. your sidebar - then you can do by calling a PHP function.
It uses the same parameters as above, each seperated by an ampersand.
For example...
simple_timed_content(ondate=20100101&offdate=20101231);
This will return either TRUE or FALSE depending on whether the content should be displayed or not. So, a full example may be...
<?php if (function_exists('simple_timed_content')) : ?><?php if (simple_timed_content("ondate=20100101&offdate=20101231")) : ?> Some content goes here <?php endif; ?> <?php endif; ?>This will only display the content if it's any date during the year 2010.
Installation
- Upload the entire
simple-timed-contentfolder to yourwp-content/plugins/directory. - Activate the plugin through the 'Plugins' menu in WordPress.
- That's it - use the shortcode or function call where required.
Frequently Asked Questions
Are there any known problems?
You can't have a shortcode within a shortcode, hence any entered as content within the timed section will not work. For example, if you add a caption to an image then this uses a shortcode and, if used within a timed section will not work.
How can I get help or request possible changes
Feel free to report any problems, or suggestions for enhancements, to me either via my contact form or by the plugin's homepage.
Acknowledgements
Thanks to Jeff Kereakoglow for the onday and offday suggestions, as well as pointing out the bug with the time.
Changelog
1.0
- Initial release
1.1
- Use local time rather than server time
- Add
ondayandoffdayparameters - Added function call to allow timed content in other areas of theme
- Re-written (and simplified) logic that decides if content should be shown or not
- Minor changes and enhancements
1.1.1
- Fixed bug causing timings to not operate correctly

Known Bugs
No bugs are currently recorded.
Planned Enhancements
View the Roadmap for Simple Timed Content
View the Change Log for Simple Timed Content
















Copyright © 2000-2012
Artiss.co.uk is checked by
Note: The first example you use above:
[timed offdate="20102412"]
should be [timed offdate="20101224"]
to be consistent with the format YYYYMMDD
Great plugin, but it would be nice to have more complete instructions for publishing or unpublishing whole posts and whole pages rather than just content on a post or page.
Thanks.
I’ve corrected that – thanks.
As for the second point, this plugin doesn’t work for complete posts or pages (and hence the ommission!). I’d recommend Post Expirator for doing this.
My site is a news and announcement site which uses the “excerpt” on the post to publish a lead in to the article on the front page of the site. Is there any way to modify your plug-in so that the [timed] tags function when in the “excerpt”?
The events that are announced have opening and closing dates and with your timed content plug-in I can include different content in the article based upon the dates. I would also like to be able to use it in the “excerpt” to change content based upon the date/time.
Thanks.
David Perednia
To get this to work you simply need to enable shortcodes in excerpts. Do this by adding the following lines to your functions.php file in your theme folder…
add_filter( 'the_excerpt', 'shortcode_unautop');add_filter( 'the_excerpt', 'do_shortcode');
Hi,
Great plugin. My use case is to use it to show a form which is called with a shortcode. Though when I embed this shortcode into `[timed... ]` the shortcode for the form is not executed and it appears in plaintext. Any chance I can see my shortcode executetd or not ?
Thanks, regards,
If I interpret correctly what you’re saying, you have my timed content shortcode within another shortcode? If so, then this is a limitation of the shortcode system in WordPress. I’ve taken advantage of this, for example, by creating my own shortcode which does nothing but output the text between the shortcode tags – this allows me to show my shortcodes on the website without them being executed.
Sorry I can’t help any further.
Hello David,
Thank you for responding so quickly.
In my case, I have other shortcode embeded in yours. The idea was to use your shortcode to display a form and then remove it at a given time. But this form is called with a shortcode … !
Anyway I understand that this is a WordPress limitation. My work around for this is to put the shortcode for the form in a dedicated post and put the link to this other post inside your shortcode. And this works fine!
Thanks a lot, regards,
LB
I needed this – thanks! But am noticing that the expiration time seems to only respond to UTC time and not my local time (As set in WordPress>General); is this correct?
Thanks,
Steve
The current date and time is taken from PHP, so it reflects your host server.
David,
Thanks for the 1.1 update. I have it installed on two websites, and I seem to be having two issues, one of which is definitely related to 1.1, and the second one may or may not be.
1) 1.1 completely didn’t function in a new install I did on http://www.sunshinebicycle.com. I installed version 1.0 and it functions fine. Not sure if it’s clashing with another plugin or what.
2) On the same site, regardless of version, it wants to reveal the raw code for photo captions when a photo with a caption is wrapped with your shortcode. I didn’t notice this problem on my other installation – http://www.panchosfairfax.com – because we don’t used captions on the photos I’ve wrapped your code around.
Any thoughts or ideas?
Thanks so much for your hard work.
Steve
1) I’ve just released version 1.1.1 of the plugin, as I found a bug in the code affecting the main logic.
2) The caption uses a shortcode and, unfortunately, in WordPress you can’t have a shortcode within a shortcode – hence why the caption code is appearing when used within the “timed” shortcode. I’ll update the instructions to mention this.
Thanks.