Title: &lt;?php the_ID(); ?&gt;, javascript and the loop
Last modified: August 19, 2016

---

# <?php the_ID(); ?>, javascript and the loop

 *  [Stefan](https://wordpress.org/support/users/webcam/)
 * (@webcam)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/ltphp-the_id-gt-javascript-and-the-loop/)
 * Hello Community!
 * I would use the moo-tools slider effect in my loop.
 * In header.php
 *     ```
       <script type="text/javascript">
       		window.onload = function() {
       		    var topbar = document.getElementById('newsbox');
       		    topbar.style.height = 20 + "px";
   
       		}
   
       	</script>
       ```
   
 * in my loop:
 *     ```
       <?php   $my_query = new WP_Query('category_name=news&showposts=3');
        while ($my_query->have_posts()) : $my_query->the_post();
       $do_not_duplicate = $post->ID; ?>
   
       <div id="newsbox" onmouseover="scale_<?php the_ID(); ?>.sizeup()" onmouseout="scale_<?php the_ID(); ?>.sizedown(20)">
   
       <div class="content">
       								 <script type="text/javascript">scale_<?php the_ID(); ?> = new fx.Scaleheader('newsbox', {duration: 300});   </script>
       	CONTENT
       </div></div>
   
       <?php endwhile; ?>
       ```
   
 * THIS WILL WORK FINE: with Firefox.
 * But it wont work with Safari and Opera. These both will only slide up the first
   entry.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [stijky](https://wordpress.org/support/users/stijky/)
 * (@stijky)
 * [17 years, 6 months ago](https://wordpress.org/support/topic/ltphp-the_id-gt-javascript-and-the-loop/#post-699290)
 * I am having a similar problem, but using the thumbnailviewer II script inside
   of the post loop. It works fine in Firefox/ Safari, but anything with the js (
   for example, images with rel=””) won’t show up at all in IE (the whole div just
   disappears, even the images without javascript in the tags)
 * Is there some issue with calling javascript from inside the WP loop (I am using
   it outside of the content box, in the template, but still inside of the loop)
 *  [jbsurveyer](https://wordpress.org/support/users/jbsurveyer/)
 * (@jbsurveyer)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/ltphp-the_id-gt-javascript-and-the-loop/#post-699291)
 * I am having a slightly different situation – for each post and page I want to
   apply in the `<head>` section specific `<script>` and `<Link>` tags – so each
   posting or page can have specific formatting/styling and or operational features/
   widgets.
 * I know I can add some of these `<scripts>` and `<links>` to the header.php file
   but that is not fine-grained enough.
 * It appear wp_head() might be useful – but I don’t know how to make that call 
   specific to a particular post or page.
 * Any suggestions would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘<?php the_ID(); ?>, javascript and the loop’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 2 replies
 * 3 participants
 * Last reply from: [jbsurveyer](https://wordpress.org/support/users/jbsurveyer/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/ltphp-the_id-gt-javascript-and-the-loop/#post-699291)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
