I'm building a WordPress plugin that will create a radio station "On-Air Now" DJ rotator.

Working options panel I've built so far: http://i.stack.imgur.com/SiYde.png

I've based the idea on a PHP case statement I wrote back in 2007 where you specify the DJ's start time which is then checked against the server time.

I know how to pull the image, description, and link out of the DB and display it. I just don't know how to code the logic behind showing only ONE DJ during his/her scheduled TIME-FRAME. e.g.; 6a-9a.

Would it be?

script: "hello server, what time is it?"

server: "it's 6:25am"

script: "ok, database it's 6:25am...who is scheduled?"

database: "neal boortz"

script: "thank you sir. i will now write some HTML"

What I have built so far: https://github.com/gregrickaby/DJ-Rotator-for-WordPress/blob/master/dj-rotator-for-wordpress.php

I'm not asking for someone to write it for me. Just shove me in the right direction with the logic. Maybe a code example or two.

Thank you!

  • This should be migrated to stack as it is a php question , not a wordpress one. – Wyck Nov 18 '11 at 5:09
  • That's funny because at STACK they told me to move it here – Greg Nov 18 '11 at 14:09
  • This one can fall on either side of the fence, fine by me. :) – Rarst Nov 18 '11 at 14:24

Basically you have three parameters here:

  1. Current server time
  2. Schedule start time
  3. Schedule end time

Then your task boils down to using custom field parameters in query to request posts with two conditions:

  1. schedule start hour is smaller than current hour
  2. schedule end hour is larger than current hour

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.