Announcement Bar
The announcement bar is a strip at the very top of every page, above the top bar and the header, with one message and an optional button. The theme draws it and owns its settings; Promptless WP’s connector can change them for you.
This page covers how the theme behaves. For writing the message, choosing options and using the connector, see Announcement Bar in the Promptless WP documentation.
How to turn it on
Section titled “How to turn it on”- Go to Appearance → Customize → Announcement Bar → Announcement Bar Settings.
- Tick Enable Announcement Bar and write the Message.
- Optionally fill in CTA Button Text and CTA Button URL, choose Theme, and set Allow Visitors to Dismiss, Start Date / Time and End Date / Time.
- Select Publish.
| Option | Default |
|---|---|
| Enable Announcement Bar | Off |
| Message | Empty |
| CTA Button Text, CTA Button URL | Empty |
| Theme (Light or Dark) | Dark |
| Allow Visitors to Dismiss | On |
| Start Date / Time, End Date / Time | Empty |
When it shows
Section titled “When it shows”The bar appears on every page that uses the theme’s header, including Promptless WP Full Width pages. It does not appear on Canvas pages, which have no header.
The bar shows only when all four of these pass:
- Enable Announcement Bar is ticked.
- The Message has some text. A message of only spaces or empty tags counts as empty.
- The current time is inside the schedule. An empty start means from now; an empty end means no end. Times are in the site’s timezone from Settings → General.
- This visitor has not closed this message.
Since theme 1.5.0 the page is the same for every visitor, so a page cache can serve it. The server checks the first two, and leaves the bar out once its end date has passed. It includes a bar whose start is still ahead, so a page cached the day before still shows the bar on time. The visitor’s browser then checks the schedule and whether this visitor closed the bar, and hides it before the page appears. The bar never flashes up and then disappears.
There are two trade-offs:
- Visitors with JavaScript turned off see a scheduled bar from before its start date. They cannot close it either, since closing needs JavaScript.
- The visitor’s device clock decides the schedule. A visitor whose clock is wrong can see the bar start or end at the wrong time. The site’s own clock and timezone still set the start and end; only the comparison happens on the visitor’s device.
When a visitor closes it
Section titled “When a visitor closes it”With Allow Visitors to Dismiss on, the bar has a close button. Closing it stores a cookie in that visitor’s browser for 365 days, and the bar stays hidden for them on every page.
The cookie is tied to the message text. Change the Message and everyone sees the bar again, including people who closed the old one. Changing only the button, theme or dates, or only spacing in the message, does not bring it back.
With Allow Visitors to Dismiss off there is no close button and the bar always shows while it is enabled and scheduled. Use this for notices everyone must see.
The button
Section titled “The button”The button appears only when both CTA Button Text and CTA Button URL are filled in. It uses Promptless WP’s primary button style in its compact size. Screen readers and search engines read the button label followed by the message, so a label such as Learn more still describes where it goes.
Reusable elements
Section titled “Reusable elements”The Message can include Promptless WP
reusable element
shortcodes such as [re:phone_number], and the theme replaces them with their
current value when the page is shown. This needs Promptless WP to be active.
Limits and common problems
Section titled “Limits and common problems”- One bar for the whole site. It cannot be limited to some pages.
- The bar does not appear. Go through the four checks above in order. If you closed it yourself, clear this site’s cookies or use a private window.
- A page cache keeps showing an old message. A cached page keeps the message it was saved with until the cache refreshes. Since 1.5.0 it still hides the bar for visitors who closed it, and after the end date. Clear the cache after changing the message or turning the bar off.
- A performance plugin delays JavaScript. The theme marks its
announcement check so Cloudflare Rocket Loader, LiteSpeed Cache,
Autoptimize, WP Rocket, PageSpeed and Jetpack Boost leave it alone. If
another plugin delays scripts and a closed bar flashes back, exclude the
inline script
promptless-announcement-checkin that plugin’s settings.
Available since Promptless Theme 1.1.7.