WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to write a simple plugin. For every time a page is viewed, it will write to the MySQL database. Then, if the current hour is odd, it will set a PHP variable of $is_odd to true;

  $is_odd = false;
  if(current_hour_odd()) {
  $is_odd_json = json_encode($is_odd);

Then, it should embed the following JavaScript (note: I've already modified the theme's templates to put an on each page):

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
   var odd = <?php echo $is_odd_json; ?>;
   if(odd) {

So basically, I have no idea where to put these code snippets. What filters do I want to apply? I know this plugin seems stupid, but it's laying the groundwork for something else I want to do.

Thanks so much!

share|improve this question
up vote 2 down vote accepted

You could attach the to wp_head action http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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