Title: Show/Hide Content at Set Time
Author: Dave Clements
Published: <strong>24 Giugno 2011</strong>
Last modified: 1 Ottobre 2019

---

Ricerca i plugin

![](https://ps.w.org/shortcodes-to-show-or-hide-content/assets/banner-772x250.jpg?
rev=984372)

Questo plugin **non è stato testato con le ultime 3 versioni principali (major releases)
di WordPress**. Potrebbe non essere più mantenuto, o supportato, e potrebbe presentare
problemi di compatibilità se utilizzato con versioni più recenti di WordPress.

![](https://ps.w.org/shortcodes-to-show-or-hide-content/assets/icon-256x256.jpg?
rev=984372)

# Show/Hide Content at Set Time

 Di [Dave Clements](https://profiles.wordpress.org/thewanderingbrit/)

[Scarica](https://downloads.wordpress.org/plugin/shortcodes-to-show-or-hide-content.2.5.zip)

 * [Dettagli](https://it.wordpress.org/plugins/shortcodes-to-show-or-hide-content/#description)
 * [Recensioni](https://it.wordpress.org/plugins/shortcodes-to-show-or-hide-content/#reviews)
 *  [Installazione](https://it.wordpress.org/plugins/shortcodes-to-show-or-hide-content/#installation)
 * [Sviluppo](https://it.wordpress.org/plugins/shortcodes-to-show-or-hide-content/#developers)

 [Supporto](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/)

## Descrizione

**Like this plugin?** Consider [leaving a quick review](https://wordpress.org/support/view/plugin-reviews/shortcodes-to-show-or-hide-content)
or writing about how you’ve used it on your site – [send me a link](https://www.theukedge.com/contact/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=contact)
to that write up if you do.

This plugin is maintained on [GitHub](https://github.com/theukedge/shortcodes-to-show-or-hide-content),
so feel free to use the repository for reporting issues, submitting feature requests
and submitting pull requests.

This plugin provides shortcodes allowing you to display content or hide content 
at given dates and times. You can also combine the two to show some content at a
given time, and then hide it at another time.

There’s also a separate shortcode if you want to repeat a schedule for showing and
hiding content – for example to only show information about a radio show while it’s
on air.

#### Usage – single use

To show or hide content at one point in time, you can use the `[time-restrict]` 
shortcode. For example:

    ```
    [time-restrict off="2015-01-01"]Please enter our competition[/time-restrict]
    [time-restrict on="2015-01-01"]Sorry, this competition has closed[/time-restrict]
    ```

If you do not enter a time with the date, it will default to 00:00:00, so in the
above example, the first message will show up until 2015-01-01 00:00:00 (i.e. until
the first second of 2015) and the second message will show up from 2015-01-01 00:
00:00 (i.e. from the first second of 2015)

You can use any date or time string [supported by PHP](http://www.php.net/manual/en/datetime.formats.php),
such as:

    ```
    [time-restrict off="September 10th, 2014"]Will display until 09/10/2014[/time-restrict]
    [time-restrict off="2014-09-10"]Will display until 09/10/2014[/time-restrict]
    [time-restrict off="10-Septmber 2014"]Will display until 09/10/2014[/time-restrict]
    [time-restrict on="2014/09/10 18:00:00"]Will show after 09/10/2014 at 6pm[/time-restrict]
    ```

You can also combine starting and ending dates for the same piece of content. So
if you want some content to appear between January 1st and January 10th, you could
do the following:

    ```
    [time-restrict on="2015-01-01" off="2015-01-11"]
    This is a limited time offer
    [/time-restrict]
    ```

#### Usage – repeating schedule

To show and hide content on a recurring schedule, you can use the `[time-restrict-
repeat]` shortcode. Your options are a daily, weekly, monthly or annual schedule.

A daily schedule takes the following form:

    ```
    [time-restrict-repeat type="daily" ontime="09:00:00" offtime="17:00:00"]
    Working 9 to 5
    [/time-restrict-repeat]
    ```

Note that you can also cross over midnight, so to only show something from 10PM 
to 5AM, you can use:

    ```
    [time-restrict-repeat type="daily" ontime="22:00:00" offtime="05:00:00"]
    For the night owls
    [/time-restrict-repeat]
    ```

A weekly schedule takes the following form:

    ```
    [time-restrict-repeat type="weekly" onday="Monday" offday="Friday"]
    The work week
    [/time-restrict-repeat]
    ```

You can also specify start and stop times if you want (it will assume starting at
00:00:00 and ending at 23:59:59 if these are left out, like above):

    ```
    [time-restrict-repeat type="weekly" onday="Friday" offday="Monday" ontime="17:00:00" offtime="08:00:00"]
    It's the weekend baby!
    [/time-restrict-repeat]
    ```

A monthly schedule takes the following form:

    ```
    [time-restrict-repeat type="monthly" ondate="01" offdate="07"]
    The first week of the month
    [/time-restrict-repeat]
    ```

You can both cross over the end of the month, and apply times to your start and 
end dates, e.g.

    ```
    [time-restrict-repeat type="monthly" ondate="25" offdate="05" ontime="17:00:00" offtime="08:00:00"]
    We are exceptionally busy at the end of each billing cycle. Please bear with us!
    [/time-restrict-repeat]
    ```

And lastly, an annual schedule takes the following form:

    ```
    [time-restrict-repeat type="annually" onmonth="June" offmonth="August" ondate="01" offdate="31"]
    I'm currently in the mountains enjoying the summer!
    [/time-restrict-repeat]
    ```

You can cross over the end of the month or even the end of the year, and apply times
to your start and end dates, e.g.

    ```
    [time-restrict-repeat type="annually" onmonth="December" ondate="24" offmonth="January" offdate="05" ontime="17:00:00" offtime="08:00:00"]
    Our employees are currently enjoying time with their families for Christmas. We'll be back after the New Year.
    [/time-restrict-repeat]
    ```

If you’re feeling creative, you can even nest shortcodes to account for multiple
concurrent conditions. Since you cannot nest shortcodes with the same name, you 
need to add -2 or -3 to time-restrict-repeat in your shortcode (e.g. `[time-restrict-
repeat-2]`).

For example, showing a message during business hours only on Monday to Friday:

    ```
    [time-restrict-repeat type="daily" ontime="08:00:00" offtime="17:00:00"]
    [time-restrict-repeat-2 type="weekly" onday="Monday" offday="Friday"]
    Our store is currently open
    [/time-restrict-repeat-2]
    [/time-restrict-repeat]
    ```

You can also define a message which should appear if your content is not showing
by using the `else` attribute @since 2.5. For example, you could invite people to
visit your store during opening hours and ask them come back soon otherwise, like
this:

    ```
    [time-restrict-repeat type="daily" ontime="08:00:00" offtime="17:00:00" else="We're currently closed. Come back and see us when we're open."]
    [time-restrict-repeat-2 type="weekly" onday="Monday" offday="Friday" else="We're currently closed. Come back and see us when we're open."]
    Our store is currently open
    [/time-restrict-repeat-2]
    [/time-restrict-repeat]
    ```

Note that with nested shortcodes, you need to add the `else` attribute to each shortcode.

#### Things to bear in mind

 * The time used by the plugin is your site’s local time (check in Settings > General).
 * The `else` attribute _does_ accept HTML, but is restricted by [WordPress’ limitation on HTML inside shortcode attributes](https://codex.wordpress.org/Shortcode_API#HTML).

I also run [Do It With WordPress](http://www.doitwithwp.com/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=my-other-sites),
which has an array of tutorials for managing, modifying and maintaining your WordPress
sites, as well as [The WP Butler](https://www.thewpbutler.com/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=wordpress-services),
a service for keeping your site maintained, backed up, updated and secure.

## Installazione

 1. Upload `shortcodes-to-show-or-hide-content.zip` to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Use shortcodes around your text

## FAQ

  How do I get the plugin to do “this”?

Check the [Description tab](https://wordpress.org/plugins/shortcodes-to-show-or-hide-content/description/)
for several examples showing what the plugin can do.

If you’re still stuck, the best thing to do is to submit an issue on [GitHub](https://github.com/theukedge/shortcodes-to-show-or-hide-content/issues).
If you don’t have a GitHub account, then [get in touch with me](https://www.theukedge.com/contact/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=contact)
and I’d be glad to help you out.

  Can you add a feature to this widget?

Probably. The best thing to do is to create a new feature request on [GitHub](https://github.com/theukedge/shortcodes-to-show-or-hide-content/issues).
If you don’t have a GitHub account, then [tell me](https://www.theukedge.com/contact/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=contact)
what this widget should do that it doesn’t currently.

  Something’s not right. What should I do?

The best thing to do is to submit an issue on [GitHub](https://github.com/theukedge/shortcodes-to-show-or-hide-content/issues).
If you don’t have a GitHub account, then [get in touch with me](https://www.theukedge.com/contact/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=contact)
and I’ll see about getting it fixed.

## Recensioni

![](https://secure.gravatar.com/avatar/c5d675a937ef0a3b2b1d679cc02848747e0e91aae1be2dbdffa810b10d740fa4?
s=60&d=retro&r=g)

### 󠀁[Hide and Show WP Forms](https://wordpress.org/support/topic/hide-and-show-wp-forms/)󠁿

 [cecnaadmin](https://profiles.wordpress.org/cecnaadmin/) 18 Giugno 2021

Perfect! We have a form for the new guests that allows us to make a donation to 
a charity of their choice. We can't have people using this form all week long. This
is great, turns on when we offer, turns off after the event. Yes!! We put the WPforms
shortcode between the Time restrict.

![](https://secure.gravatar.com/avatar/3d5945b26f83744960b05cc5f0e6e0f882a8d4bc84d5a4b4e4be523a14cf6806?
s=60&d=retro&r=g)

### 󠀁[Outstanding](https://wordpress.org/support/topic/outstanding-473/)󠁿

 [verysiberian](https://profiles.wordpress.org/verysiberian/) 21 Gennaio 2021 1 
risposta

Thank you for this powerful and easy to use plugin. It does exactly what I need.
I am using it for educational purposes. Specifically, we want to make some information
available at exactly 30 minutes before an exam starts. With your plugin, we are 
able to set everything up in advance and not worry about it. I hope that you continue
to develop and support it! Thanks so much.

![](https://secure.gravatar.com/avatar/2330ed20ad69d160b3ab8f844993ce807aa71faf8853e07803eb520351ece072?
s=60&d=retro&r=g)

### 󠀁[Great help](https://wordpress.org/support/topic/great-help-162/)󠁿

 [imorton777](https://profiles.wordpress.org/imorton777/) 2 Giugno 2020

Even worked with my other wp shortcodes so I could display forms during business
hours.

![](https://secure.gravatar.com/avatar/0e0f163cff45d47762e6352bac467f6b33badfd78b12817fe37f086d467ae71d?
s=60&d=retro&r=g)

### 󠀁[Exactly what I needed !](https://wordpress.org/support/topic/exactly-what-i-needed-686/)󠁿

 [dregad](https://profiles.wordpress.org/dregad/) 22 Aprile 2020 1 risposta

I had to publish a contact form on my site, but only after a certain date, and leave
it open during a limited period. Your plugin did the job perfectly ! Many thanks
for your efforts in developing it, much appreciated !

![](https://secure.gravatar.com/avatar/3a1e6fe5cd7c365ee7f4f09ce4615dcd9f610b329c4ecc9305ee2e6b6a124540?
s=60&d=retro&r=g)

### 󠀁[Simple and effective](https://wordpress.org/support/topic/simple-and-effective-1074/)󠁿

 [gsmphone](https://profiles.wordpress.org/gsmphone/) 31 Gennaio 2020

It works perfectly, after trying others this has worked perfectly

![](https://secure.gravatar.com/avatar/1eb26fab4b3fff03f0f4bd29a65f82f03e12cd3e67abfc6f9f1b94a5980a73cd?
s=60&d=retro&r=g)

### 󠀁[Excellent plugin](https://wordpress.org/support/topic/excellent-plugin-4369/)󠁿

 [gfdesign](https://profiles.wordpress.org/gfdesign/) 4 Novembre 2018

This helped me to create a radio statioon website. Thanks for your plugin. Best 
regards

 [ Leggi tutte le recensioni di 33 ](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/reviews/)

## Contributi e sviluppo

“Show/Hide Content at Set Time” è un software open source. Le persone che hanno 
contribuito allo sviluppo di questo plugin sono indicate di seguito.

Collaboratori

 *   [ Dave Clements ](https://profiles.wordpress.org/thewanderingbrit/)

[Traduci “Show/Hide Content at Set Time” nella tua lingua.](https://translate.wordpress.org/projects/wp-plugins/shortcodes-to-show-or-hide-content)

### Ti interessa lo sviluppo?

[Esplora il codice](https://plugins.trac.wordpress.org/browser/shortcodes-to-show-or-hide-content/)
segui il [repository SVN](https://plugins.svn.wordpress.org/shortcodes-to-show-or-hide-content/),
segui il [log delle modifiche](https://plugins.trac.wordpress.org/log/shortcodes-to-show-or-hide-content/)
tramite [RSS](https://plugins.trac.wordpress.org/log/shortcodes-to-show-or-hide-content/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 2.5

Release date: December 14, 2016

 * Addition of `else` parameter.
 * Retire old (pre v2.0) shortcodes.

#### 2.4

Release date: May 23, 2016

 * Coding standards, logic and performance improvements.

#### 2.3.1

Release date: August 31, 2015

 * Corrected an error in the weekly logic (props [Jérôme](https://github.com/Grome13))

#### 2.3

Release date: December 5, 2014

 * Introduced recurring annual schedule (previously only monthly/weekly/daily). 
   Just use type=”annually” in your shortcodes.
 * Code improvements.

#### 2.2

Release date: October 9, 2014

 * Fixed inability to nest shortcodes by introducing distinct copies of the time-
   restrict-repeat shortcode (`[time-restrict-repeat-2]` and `[time-restrict-repeat-
   3]`)

#### 2.1.1

Release date: October 2, 2014

 * Fixed error where content would show all the time when either onday and offday
   matched, or offdate and ondate matched.

#### 2.1

Release date: August 30, 2014

 * Revised code to allow for onday and offday being the same. Same for ondate and
   offdate.
 * Changed attributes for `[time-restrict]` shortcode to be more in line with the
   rest of the plugin. Now using ‘on’ and ‘off’ instead of ‘show’ and ‘hide’, though
   the show and hide attributes will continue to work.

#### 2.0

Release date: August 22, 2014

 * New combined `[time-restrict]` shortcode allows for hide and show times for the
   same piece of content
 * New `[time-restrict-repeat]` shortcode allows you to show and hide content on
   a daily, weekly or monthly recurring basis
 * Code improvements
 * Legacy shortcode support
 * Enables nesting shortcodes within new shortcodes
 * Plugin now respects site’s local time, rather than server time

## Meta

 *  Versione **2.5**
 *  Ultimo aggiornamento **7 anni fa**
 *  Installazioni attive **10.000+**
 *  Versione WordPress ** 2.5 o superiore **
 *  Testato fino alla versione **5.2.29**
 *  Lingua
 * [English (US)](https://wordpress.org/plugins/shortcodes-to-show-or-hide-content/)
 * Tag
 * [active](https://it.wordpress.org/plugins/tags/active/)[date](https://it.wordpress.org/plugins/tags/date/)
   [expire](https://it.wordpress.org/plugins/tags/expire/)[show hide](https://it.wordpress.org/plugins/tags/show-hide/)
   [time](https://it.wordpress.org/plugins/tags/time/)
 *  [Visualizzazione avanzata](https://it.wordpress.org/plugins/shortcodes-to-show-or-hide-content/advanced/)

## Valutazioni

 4.9 su 5 stelle.

 *  [  32 recensioni a 5-stelle     ](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/reviews/?filter=5)
 *  [  0 recensioni a 4-stelle     ](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/reviews/?filter=4)
 *  [  0 recensioni a 3-stelle     ](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/reviews/?filter=3)
 *  [  1 2- recensioni a stelle     ](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/reviews/?filter=2)
 *  [  0 recensioni a 1-stelle     ](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/reviews/?filter=1)

[La tua recensione](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/reviews/#new-post)

[Vedi tutte le recensioni](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/reviews/)

## Collaboratori

 *   [ Dave Clements ](https://profiles.wordpress.org/thewanderingbrit/)

## Supporto

Hai qualcosa da dire? Ti serve aiuto?

 [Chiedi nel forum di supporto](https://wordpress.org/support/plugin/shortcodes-to-show-or-hide-content/)

## Dona

Vuoi supportare lo sviluppo di questo plugin?

 [ Fai una donazione per questo plugin ](https://www.theukedge.com/donate/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=donate)