Control the Visibility of WordPress Widgets Based on Time and Date

photo credit: Βethan - cc
photo credit: Βethancc

The traditional use of widgets in WordPress is to set it and forget it. After placing and configuring a widget, it stays in the widgetized area until manually removed. Many plugins have extended widgets to add visibility settings that are based on the page or post where the widget appears. But what if you could also control widgets based on time and date?

The new Widget Visibility Time Scheduler plugin actually allows you to schedule the display of widgets down to the minute. The plugin, created by WordPress developer Martin Stehle, adds time-based visibility settings to each widget’s configuration options.

widget-visibility

Widget Visibility Time Scheduler was designed to work seamlessly with Jetpack’s Widget Visibility module, which allows you to limit widget display to certain pages. There is no conflict if your site is Jetpack-enabled and you can even use the two visibility options in combination with one another.

The plugin is perfect for seasonal widgets, temporary sales/promotions, events, live chat buttons, and any other time/date-dependent content. One feature that might be useful to add is an indefinite option for the end time of the widget display. That would enable users to schedule future widgets and leave them in place indefinitely. Additionally, an option to set the widget display based on the day of the week could offer more flexibility.

After testing the plugin, I can confirm that it works as advertised. If you try the plugin and you want to remove it at a later point in time, you’ll need to uncheck the widget visibility time scheduler box in each widget before you remove that plugin. This will ensure that none of its data remains in the database after you remove the plugin.

Widget Visibility Time Scheduler is a handy addition to any site using WordPress as a CMS, an e-commerce platform, or even a blog. In combination with the Jetpack module, it offers full control over when and where your widgets are displayed. This is one you may want to favorite for the next time you need to use it. The plugin is available for download from WordPress.org.

11 Comments


  1. “The plugin is perfect for seasonal widgets, temporary sales/promotions, events, live chat buttons, and any other time/date-dependent content.” Wow, this is what I have been waiting for a long time. Thank you for sharing this. I am going to give it a try now.

    Report


  2. OK, I installed on my site and it works beautifully! The only thing you need to pay attention to is that it uses UTC time, and it took me some time to set it up correctly. I added a text widget on my site and set it to be visible until this Friday, and I will see if it will go away on Saturday.

    Report


    1. @Jeffrey: After I have read the documentation of WordPress’ time functions I can confirm that you are right saying the plugin uses UTC. In the next version of the plugin the local blog time (as set on the general settings page) will be considered instead of UTC.

      Report


  3. Sarah, thank you for your detailed article. I am the plugin author and open for all new aspects of the plugin.

    The option to select days of week is in progress.

    In the article you have mentioned the idea of an indefinite option for the end time of the widget display. What about to implement that as a checkbox?
    Because of technical limitations the highest and safest year number is 2037. What about instead of a checkbox a short text telling the user that he/she can give in a high number up to 2037 of year to realize “indefinite” visibility?

    Report


  4. Jeffrey, the plugin does not use UTC, but the time of the server. So it seems your server uses UTC (and the plugin adopt that).

    Do you think the usage could be better? Any idea to improve the plugin is welcome.

    Report


    1. Thanks for the explanation. I like the idea of using a checkbox for an indefinite option, instead of using textbox. By the way, why the highest number is 2037? Is it something related to PHP, WP, or MySQL?

      Report


  5. This Plugin seems really handy, gonna check it out and hopefully use it in some projects.

    Report


  6. @Jeffrey: it is because of two things: how the current time is count and the operating system and applications which handle time data (like Apache, MySQL, PHP).

    You will find a very detailed (and understandable) explanation at Wikipedia “Year 2038 problem”: http://en.wikipedia.org/wiki/Year_2038_problem

    So the maximum time on 32-bit systems is 03:14:07 on Tuesday, 19 January 2038. Because a user of the plugin can type in a date after 19 January 2038 an error can occur. So in the plugin I set the maximum valid year value to 2037 to allow dates up to December 31, 2037 and to avoid a more complicated check for a date like “January 19, 2039”.

    Could that answer your question understandable?

    Report


  7. @Martin, thank you so much for your detailed explanation. I learned something new today. :-)

    Report


  8. All your ideas and wishes are now implemented in the new plugin version 2.0. If you find them useful I would be glad if you would leave a review in the WordPress plugin page.

    Report

Comments are closed.