• report-gisolcom

    (@report-gisolcom)


    Hi all,

    This may be a little complicated, but I hope someone can help πŸ˜‰

    I would like each post to have a time range and have a different output depending on the time of day. All my posts are adverts for different businesses, and I want to display if they are open or not. As well as on the post itself, it will display on the category listing for each post.

    I was thinking of tagging each post with whole hours. If the business was open between 1pm and 5pm, then I would tag with 13, 14, 15, 16 then I could use the if(has_tag(”)) to compare to the server time and if match then output an “Open” image or text. If the tag and server time don’t match, then output a “Closed” image or text.

    Unfortunately if I did that, I would have to have 24 if(has_tag(‘)) statements and if they open at 9.30am it would be wrong for half an hour. I also don’t know the php code to compare the tag to the server time.

    Can anyone help, or think of an easier way to do it?

    Many thanks in advance!!!!

Viewing 4 replies - 1 through 4 (of 4 total)
  • esmi

    (@esmi)

    What about using custom meta fields?

    http://codex.wordpress.org/Using_Custom_Fields

    Thread Starter report-gisolcom

    (@report-gisolcom)

    Thanks esmi.

    I will look into it.

    Any other ideas people?

    t31os

    (@t31os)

    I’d agree with esmi and use custom fields to…

    You’ll need some PHP to accompany it, but custom fields would be my choice if i needed to do such a thing…

    Why? : If you use custom fields, you’d only need 2, one for the opening time and another for the closing time.

    Of course if you have anywhere listed that has multiple opening times, say on different days, then the PHP becomes more complex, but still doable…

    You could expand on the custom fields in such a case, and have a second or third set of fields when alternate opening times exist..

    Hurts me head just thinking about how to do it though… hehe πŸ™‚

    Thread Starter report-gisolcom

    (@report-gisolcom)

    Thanks t31os,

    Yes, some have different opening times for different days of the week and some open twice per day. It is going to be really difficult!!

    Anyone got any tips, they would be gratefully received! πŸ™‚

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Different output for time of day for each post’ is closed to new replies.