Title: Thickbox repeating windows script problem
Last modified: August 19, 2016

---

# Thickbox repeating windows script problem

 *  Resolved [rebekahford](https://wordpress.org/support/users/rebekahford/)
 * (@rebekahford)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/thickbox-repeating-windows-script-problem/)
 * Hello
 * I’m using thickbox to make an overlay on my homepage and category pages. I have
   a random number of posts pulled into each of these pages. i am calling thickbox
   on the li.post element with the following settings
 * `<a href="<?php the_permalink() ?>?KeepThis=true&height=450&width=805&modal=true"
   title="<?php printf(__('%s', 'veryplaintxt'), wp_specialchars(get_the_title(),
   1)) ?>" class="thickbox">`
 * and using the Q2W3 plugin to call thickbox.
 * The problem is that when i click on one of the posts the first time, everything
   seems to work fine. If i then close the page and click on another post, the main
   overlay loads ok but i get the TB_Title and TB_AjaxContent boxes repeating once
   with the first AjaxContent box containing the content and the second TB_Title
   and AjaxContent box underneath it blank.
 * If I close this and open another I get 4 boxes, next time 16 and so on.
 * Obviously the script is being called several times but I can’t think why, except
   that the window being called into the AjaxContent box is the single.php template
   which also calls the same header scripts as the main window thus calling thickbox
   again within it. I haven’t tested it by removing the header from single.php yet
   as I wondered if there’s a way of disabling it another way and not having to 
   rewrite a new header.
 * Is this indeed the problem or is it something else. I read somewhere else that
   I could alter the init but i don’t want to be hacking at the core
 * Any help greatly appreciated as I’m running out of time
 * regards
 * Rebekah

Viewing 1 replies (of 1 total)

 *  Thread Starter [rebekahford](https://wordpress.org/support/users/rebekahford/)
 * (@rebekahford)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/thickbox-repeating-windows-script-problem/#post-1882874)
 * I found out that it is indeed that when using thickbox in ajax/modal mode, the
   content that you’re calling in i.e. the single.php template in this case, should
   not also be calling thickbox itself somewhere, hence the never ending loop!
 * I have fixed this myself by doing this
 * 1. I deactivated the plugin as i had no control as to what pages it appeared 
   on and this was lazy anyway
    2. I downloaded thickbox 3.1 from the thickbox site
   and uploaded the js and css files to my theme (i will be looking into shadowbox
   next time). 3. I added some conditionals to my header so that I could control
   which pages are calling thickbox. I only need the category and homepage to call
   it:
 *     ```
       <?php if (is_home() || is_category()) { ?>
         <script src="<?php bloginfo('template_directory'); ?>/js/thickbox3.1.js" type="text/javascript"></script>
         	<script language="javascript" type="text/javascript" name="homecat_scripting">
       			$(document).ready(function() {
       				//********* thickbox pop ups
       				jQuery("li.post").parent("a").addClass("thickbox");
       	});
               </script>
       <?php  }?>
       ```
   
 * 4. I had another conditional for the single.php template
 *     ```
       <?php if (is_single()) { ?>
       only single page jquery went in here
       <?php  }?>
       ```
   
 * thus making my header code more efficient
 * It now works a treat thank heavens! Hope this helps anyone else who gets this
   problem

Viewing 1 replies (of 1 total)

The topic ‘Thickbox repeating windows script problem’ is closed to new replies.

## Tags

 * [repeat](https://wordpress.org/support/topic-tag/repeat/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [rebekahford](https://wordpress.org/support/users/rebekahford/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/thickbox-repeating-windows-script-problem/#post-1882874)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
