All 20 Countdown Timer sections

See every section

Show or hide part of a page when the countdown ends

Updated Countdown Timer 1.12.0Tested with WordPress 7.1

When the timer ends changes the timer. To change the page around it, put the content in a Countdown content block, or in the [trasl_countdown_show] shortcode, and choose a campaign and when the content shows:

  • While it runs: from the campaign's start to its end. The sale's banner, or its code.
  • After it ends: from the end on. "The sale has ended. Join the list for the next one."
  • Before it starts: until the campaign's Start date and time. "The sale opens on Friday at 9:00."
[trasl_countdown_show campaign="Black Friday" when="running"]Use code BF20 at the checkout.[/trasl_countdown_show]
[trasl_countdown_show campaign="Black Friday" when="ended"]The sale has ended.[/trasl_countdown_show]

when is running, ended (or after) or before, and running when it is left out. The campaign is named as in [trasl_countdown]: by the ID Campaigns copies, or by its name. In the block editor the block's settings offer your campaigns and the three moments, and the top of the block says which campaign and moment it is for and whether it shows on the site now. A campaign used only this way needs no placement ticked.

The change happens in the browser, at the second the timer for the same campaign reaches zero, with no reload. It goes by the same clock as the timers, so it is the same second on every timer and every block on the page.

What the page carries. The server decides what a page shows when it is drawn, so a page is right without JavaScript as of that moment. Content for a moment still to come is in the page, hidden, so it can appear at that moment, and the page carries a one-line rule that keeps it hidden whatever display your theme gives its blocks. Content for a moment that has passed is not sent at all: once a fixed-date campaign has ended, its "While it runs" content is no longer in the page, and "Before it starts" content goes at the start. Content still to come can be read in the page's source, so a code that must not work before or after the sale belongs in a coupon linked to the campaign (see A coupon that works only while the countdown runs), which WooCommerce refuses outside the window.

Each kind of campaign.

  • Fixed date and time: all three moments, at the campaign's start and end.
  • Fixed length per visitor: each visitor's content changes at the end of their own countdown, so two visitors see the change at different times. "While it runs" content is the offer itself, so showing it starts the visitor's countdown, as a timer does. "After it ends" content shown alone starts nobody's countdown. A page drawn for a visitor whose countdown has ended is not kept by page caches, as with the timer.
  • Product sale end date and Daily or weekly cut-off end per product or every day, not for the whole page. "Before it starts" and "While it runs" go by the campaign's start date; "After it ends" never shows.

While the campaign is switched off, or every campaign is switched off under Settings, none of its content shows. Someone who can edit posts sees why where the content would be: no campaign chosen, a campaign that no longer exists, one switched off, "Before it starts" on a campaign with no start date. Visitors see nothing there.

Page caches. The first time content for a campaign is shown, the campaign's start and, on a fixed date, its end are booked to empty the page caches the plugin knows, the same ones a campaign save empties. A page cached before the end is thrown away at the end, and the next visitor gets one drawn after it. A copy from before the end that is still served after it, because WP-Cron ran late on a quiet site or the cache is one the plugin cannot empty (a host's own cache can listen for trct_purge_caches), is put right by the script as the page loads: the old content goes and the new appears. Until the script runs, and in a browser without JavaScript, that copy shows what it showed when it was cached.

Screen readers and the keyboard. Hidden content is out of the keyboard's and a screen reader's reach until it shows. Content that appears is not read out by itself: it is part of the page, not a message, and reading out a whole section would talk over whatever somebody was doing. When the keyboard was inside content that goes, the focus moves to the content that takes its place, so nobody is left on something no longer there.

Without the plugin. On a site where the plugin is deactivated or removed, a Countdown content block shows nothing, so a code meant only for the sale is never shown by a site that cannot tell when the sale ends. A shortcode, like any shortcode, shows as typed, its content included, so use the block for a code.

WordPress 6.0 to 6.3. The block keeps its content in a box marked hidden. Before WordPress 6.4, saving a post took that mark off for anybody without the right to post unfiltered HTML: authors, editors, and every site administrator on a network. The block then showed as invalid content when the post was opened again, and a site without the plugin showed what was in it. The plugin now lets the box keep its mark on those versions. A block saved that way earlier is read as the block it is, and saved hidden again the next time the post is saved.

Still stuck? Ask the developers who wrote it. We aim to reply within one business day.