Menu
All plugins

Content Expiry

A shortcode that takes expired offers and old announcements offline. Wrap the content in [content_expiry], set a date, and it is removed from the page after that moment. Nothing is left behind: no empty wrapper, no hidden markup.

Version: 0.1.0 · Requires: WordPress 6.0+, PHP 7.4+ · See the live demo

Installation

  1. Upload and activate the plugin. There are no settings.
  2. Wrap the content in the shortcode and give it a date.

Quick start

[content_expiry date="2026-12-31"]Book before the end of December and save 10%.[/content_expiry]

By default the content stays up for the whole of that day and is gone from midnight.

Attributes

  • date (required). When the content comes offline. Accepted formats: 2026-12-31, 31/12/2026 (day first), 31 December 2026, or with a time: 2026-12-31 18:00.
  • time. Go offline at an exact time on that date: 18:00 or 6pm.
  • timezone. For example Europe/London. Defaults to the site timezone (Settings, General).
  • start. Hold the content back until this date or time, in the same formats. Handy for scheduling an offer in.
  • fallback. Short text shown instead once the content has expired, for example fallback="This offer has ended."

Examples

[content_expiry date="2026-11-30" time="23:00" start="2026-11-01"]Black Friday offer[/content_expiry]

[content_expiry date="2026-12-31" fallback="Early-bird pricing has ended."]Early-bird price: £1,200[/content_expiry]

Shortcodes inside the block

Other shortcodes inside the block work as normal. To put one expiry block inside another, use [content_expiry_2] for the inner one.

Editing and previewing

  • Inside the Bricks builder and wp-admin the content always shows, so you can still edit it.
  • Logged-in editors can preview any moment on the front end: add ?content_expiry_preview=2027-01-01 (or 2026-12-31 18:30) to the page URL.
  • A missing or unreadable date never hides content. The block stays visible and editors see a short warning above it.

Page caching

A cached page would otherwise keep showing expired content. Whenever a page is built with a pending expiry, the plugin records the page against that moment and schedules one WP-Cron event to purge it right then. LiteSpeed, WP Rocket, W3 Total Cache, WP Super Cache and Super Page Cache for Cloudflare are handled. On LiteSpeed it also caps that page’s cache lifetime to the time remaining.

  • WP-Cron needs a visit or a real server cron hitting wp-cron.php to fire on time. Use a real cron for exact-to-the-minute expiry.
  • If more than 200 pages carry the same expiry moment (a site-wide banner, say) the plugin clears the whole cache once instead.

Troubleshooting

  • The content is still showing after its date: a cache plugin that is not on the list above may be serving the old page. Clear the cache, or hook the action below to purge it automatically. Without a real server cron, expiry also waits for the next visit to fire WP-Cron.
  • The time is an hour out: set timezone on the shortcode, for example timezone="Europe/London", especially if the site timezone is a plain UTC offset.
  • I see a warning above the content: the date is missing or cannot be read. The content stays visible until it is fixed.

For developers

  • content_expiry_purged is an action that fires when a page is purged at its expiry moment. It passes $url and $post_id, so other caches can hook it.

Known limits

  • Content is removed on the server, so it is not in the page source after expiry.
  • Nothing is stored except short-lived purge records.