WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
timed widget (7 posts)

  1. pyrohot
    Member
    Posted 1 year ago #

    If i want to show widget from 23.00 till 06.00 in morning, then is this code correct?

    $hour = date_i18n('G'); if ($hour > 22 && $hour < 7 ) return true;

    http://wordpress.org/extend/plugins/widget-logic/

  2. pyrohot
    Member
    Posted 1 year ago #

    i cant get it to work. is somewhere samples ho to use this plugin?

  3. alanft
    Member
    Plugin Author

    Posted 1 year ago #

    try changing the first bit to
    $hour = 0+date_i18n('G')

    which makes $hour an integer instead of a string so that the second bit works reliably. the other thing to check is to print out date_i18n('G') somewhere (via a PHP widget would work) so you can check what your server thinks is the local time.

  4. pyrohot
    Member
    Posted 1 year ago #

    thanx, but i dont understand nothing from WP's Conditional Tags - i'm total noob and found this code somewhere in wp forum. I try to use this in adrotate widget to show some ads only in nights, but i cant get it to work.
    So now i tried:
    $hour = 0+date_i18n('G'); if ($hour < 22 || $hour > 7 ) return true;

    but it wont work for me...

  5. alanft
    Member
    Plugin Author

    Posted 1 year ago #

    it should definitely be && (that is 'AND') and not || (which is 'OR') to work. But if it's not working then perhaps date_i18n isn't working as expected on your install, and you'll have to work out some way of checking what it is doing.

  6. pyrohot
    Member
    Posted 1 year ago #

    i made echo date_i18n('G'); and server time is correct. i tried to use logic in adrotate widget.. maybe adrotate wont work?

  7. pyrohot
    Member
    Posted 1 year ago #

    i give up, server time is correct...
    code in wiget is correct as:
    $hour = 0+date_i18n('G'); if ($hour > 22 && $hour < 7 ) return true;

    and its not working

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.