Timed Display of Content: the rsvpmaker_timed Shortcode

Part of the point of using a calendar plugin on your blog is to have content displayed for upcoming events, but not past ones, or at least give the upcoming events people can sign up for or attend greater emphasis and display them in chronological order (rather than the reverse chronological order of a blog listing).

I always think it looks stupid for a website to be promoting an event that is already past. Computers can tell time, and we should let them do so on our behalf rather than waiting for the webmaster to get around to removing the outdated content.

Events aren’t the only example of time-sensitive content, however. We may have limited time offers or other content that has a start date, an end date, or both. WordPress lets you schedule posts to go live at a given time in the future, but what if you want to embed a bit of limited time content on your home page or somewhere else on your site?

That’s the purpose of the rsvpmaker_timed shortcode, which can be wrapped around any bit of content in a page or a post that should only be displayed after a given time, until a given time, or between a start time and an end time. For those not familiar, a shortcode is a code you enter into the WordPress editor that achieves a special effect. Here is an example:

rsvpmaker_timed coding wrapped around a paragraph for conditional display.
rsvpmaker_timed coding wrapped around a paragraph for conditional display.

This shows the shortcode open and close tags wrapped around a paragraph, but it could just as easily be a longer block of content including images or video.

The shortcode attributes are start, end, too_early, and too_late. Put a plain language date like ‘January 1, 2016 7 pm’ in the start and/or end fields, or use a database style date like ‘2016-01-20 19:00′ and RSVPMaker will test the current time against those rules.

If a visitor is coming too the site too early or too late, according to those rules, the shortcode will return either an empty string or the contents of the too_early / too_late parameters, if set. Otherwise, the content will be returned as it normally would be.

Note that if a time is not specified, in addition to the date, the time is considered to be “00:00:00″ — first thing in the very early morning of that date. So if what you really want is to specify a cutoff at midnight, you should either put in ’11:59 pm’ or ’23:59:59′ as the end time. Alternatively, if you want content to stop being shown after January 29 is over, you could set end=”January 30, 2016”

In the context of my recent projects using Google Hangouts on Air as a webinar platform, one of the ways I am using this is to put a promotion on a website home page until the event occurs. I can provide another block of content to be displayed after the event, directing people to the replay.

Support for this shortcode was added in release 3.6.2.