Title: [Plugin: Widget Logic] Conditional date tags?
Last modified: August 19, 2016

---

# [Plugin: Widget Logic] Conditional date tags?

 *  [benz1](https://wordpress.org/support/users/benz1/)
 * (@benz1)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/)
 * Is it possible to use the conditional is_date() tag to specify start and end 
   dates for a widget to appear? If so, what would the syntax be?
 * Thanks in advance.
 * [http://wordpress.org/extend/plugins/widget-logic/](http://wordpress.org/extend/plugins/widget-logic/)

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/page/2/?output_format=md)

 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865332)
 * [http://codex.wordpress.org/Conditional_Tags#A_Date_Page](http://codex.wordpress.org/Conditional_Tags#A_Date_Page)
   seems to say that it’s only use is to indicate a date-based archive page (like
   a year, month or day) list of posts is showing.
 * are you actually after a widget for an individual post dated in a specific range,
   or are you after a specific date-range in the archive list? cos that can be done,
   just not with is_date
 *  [cozbaldwin](https://wordpress.org/support/users/cozbaldwin/)
 * (@cozbaldwin)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865344)
 * I think I, too, am looking for what Benz1 wants: A widget that (hopefully via
   Widget Logic) will only display in the sidebar for a certain period of time and
   disappear once a date’s been reached.
 * For instance, a Text widget with a home-made advertisement in it which the client’s
   paid to have displayed until February 14th. I’d love for Widget Logic to know
   when it’s February 14th and stop displaying the content rather than try to remember
   to log in and deactivate the widget myself.
 *  Thread Starter [benz1](https://wordpress.org/support/users/benz1/)
 * (@benz1)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865345)
 * I’ve actually gone ahead and had a widget developed to do this. Just beta testing
   now. Give me a few days and it should be available on the repository.
 *  [cozbaldwin](https://wordpress.org/support/users/cozbaldwin/)
 * (@cozbaldwin)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865346)
 * Wonderful. Definitely post an update here when it’s ready. I’ll be using it. 
   But I’d still love to know if Widget Logic can already do this somehow. If not,
   alanft, consider this a recommendation to add the capability to your most excellent
   plugin.
 *  [zestylemon](https://wordpress.org/support/users/zestylemon/)
 * (@zestylemon)
 * [15 years ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865420)
 * I too wish dates could be used in Widget Logic. Any word from the developer as
   to whether this is on the roadmap or not?
 * Benz1: Did your widget pass beta testing? Have you added it to the repository?
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [15 years ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865421)
 * something like
 * return mktime(0, 0, 0, 7, 1, 2011) < time() && time() < mktime(0, 0, 0, 7, 31,
   2011)
 * should only show in July 2011. [mktime](http://www.php.net/manual/en/function.mktime.php)
   params are h/m/s/mon/day/year
 *  [cozbaldwin](https://wordpress.org/support/users/cozbaldwin/)
 * (@cozbaldwin)
 * [15 years ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865422)
 * Yes! Although, that doesn’t work.
    (even with the word “return” taken out, as
   I don’t think that should be there in the first place)
 *  [Lynda](https://wordpress.org/support/users/lyndasu/)
 * (@lyndasu)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865423)
 * Use the date function. For example, I programmed a widget to only display if 
   the day is Wednesday:
 * `date("l")=='Wednesday'`
 * Any of the [PHP date formats](http://php.net/manual/en/function.date.php) should
   work here.
 *  [cozbaldwin](https://wordpress.org/support/users/cozbaldwin/)
 * (@cozbaldwin)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865424)
 * Hmmm. Well, not knowing php too well, how would you use the php dates to say “
   if date is at least May 18 2011 AND is not after May 31 2011”?
 *  [Lynda](https://wordpress.org/support/users/lyndasu/)
 * (@lyndasu)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865425)
 * oh, you want to use the date of the **post** to conditionally display widgets?
   My use is for the current date to conditionally display widgets.
 * I think your way would require another loop to pull out the post date, which 
   sounds messy, if not impossible with this plugin. A better way to do it might
   be to write some PHP to call for the post date and do the calculations in the
   header and then pass the resulting variable along to the widget.
 * For example, you could grab the post month, day, year and then write an if statement
   assigning a specific variable value between the dates in question, then use that
   in the widget box (`$myvariable == 'yes'`)
 * That will take some thought though. I’m thinking out loud here in case anyone
   with more time than I do right now wants to try it.
 *  [cozbaldwin](https://wordpress.org/support/users/cozbaldwin/)
 * (@cozbaldwin)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865426)
 * No, no. Sorry. To reiterate what I’m looking for, and I think the original poster
   is looking for: A widget that will only display in the sidebar for a certain 
   period of time and disappear once a date’s been reached. (A great tool to have
   for privately paid ads)
 *  [Lynda](https://wordpress.org/support/users/lyndasu/)
 * (@lyndasu)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865427)
 * Ah! Okay, that is doable! This is what you want to put in the widget logic box:
 * `date("m.d.y") > '05.01.11' && date("m.d.y") < '05.15.11'`
 * Change 05.01.11 to the start date and 05.15.11 to the end date. Written this 
   way, you need to enter a mm.dd.yy format for the date.
 * I hope this helps!
 *  [cozbaldwin](https://wordpress.org/support/users/cozbaldwin/)
 * (@cozbaldwin)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865428)
 * Well the good news is that solution, like the mktime solution that alanft suggested,
   doesnt cause any error. The bad news is, neither of them print the widget.
 * I even went as far as to use the most complete, specific formatting possible 
   in order to test it:
    `date("D M j G:i:s T Y") > 'Wed May 18 14:18:00 EDT 2011'&&
   date("D M j G:i:s T Y") < 'Wed May 18 14:19:00 EDT 2011'`
 * I changed the time zone to make sure it wouldnt be using my server’s time zone.
   I changed it to daylight time, etc. It just doesn’t print anything. I guess something
   in the widget code itself has to be added to recognize this stuff?
 * I just went looking for another logic extender, but I can’t find any except for“
   Dynamic Widgets” — however from the screenshots, it appears as though you cannot
   set specific date ranges for specific widgets. The most specific I could get 
   is setting a date range for all Text Widgets on a certain page. 🙁
 * This seems like it would be relatively easy for the Widget Logic programmer to
   incorporate. I hope he/she does soon.
 *  [cozbaldwin](https://wordpress.org/support/users/cozbaldwin/)
 * (@cozbaldwin)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865429)
 * I am interested to see if `date("l")=='Wednesday'` and `date("l")=='January 2011'`
   
   will work, but I can’t exactly test that without waiting a month.
 *  [Lynda](https://wordpress.org/support/users/lyndasu/)
 * (@lyndasu)
 * [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/#post-1865430)
 * The more you include for the date to capture, the more likely it will be that
   you’ll screw up the value so I would definitely recommend less is more.
 * I would not recommend testing using a one minute difference, even if you know
   the server time. It’s just too hard to catch the “right time” with so little 
   room for error.
 * I tested this on my blog before I replied to you and it worked exactly as expected.
   What date values did you put in to start with the original code above?

Viewing 15 replies - 1 through 15 (of 20 total)

1 [2](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/page/2/?output_format=md)

The topic ‘[Plugin: Widget Logic] Conditional date tags?’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/widget-logic_c8dde5.svg)
 * [Widget Logic](https://wordpress.org/plugins/widget-logic/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/widget-logic/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/widget-logic/)
 * [Active Topics](https://wordpress.org/support/plugin/widget-logic/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/widget-logic/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/widget-logic/reviews/)

 * 20 replies
 * 5 participants
 * Last reply from: [Lynda](https://wordpress.org/support/users/lyndasu/)
 * Last activity: [14 years, 12 months ago](https://wordpress.org/support/topic/plugin-widget-logic-conditional-date-tags/page/2/#post-1865435)
 * Status: not resolved