Howdy! Thanks for coming and enjoy your stay! Take a look at the sitemap and don't forget to chirp!

Thickbox and jQuery in WordPress 2.8

June 15th, 2009

The update was great! The new features in WordPress 2.8 are awesome! Most of my Twitter friends have updated to 2.8 and haven’t had a single issue. The new widgets area is so cool! Oh jeez, I’m so excited. For a full features list check out Version 2.8 section in the Codex.

The WordPress 2.8 Transition

The WordPress 2.8 Transition

Anyway, the only issue I had so far is the Thickbox usage. I’m not sure why it’s lost, but I’ve discovered it in the Quick Flickr Widget plugin when upgrading. The thickbox feature worked fine in 2.7 and 2.7.1. For an unknown reason, WordPress 2.8 doesn’t call the thickbox.js file through wp_enqueue_script. The other js libraries work fine though (prototype, scriptaculous). jQuery’s being called out too btw, cause it’s a dependency of Thickbox, but thickbox never shows up. This is actually weird. I hope I’m not the only one with this issue, cause it’s starting to feel bad ;)

I’ll submit a bug ticket to their Trac for 2.8.1, but until that here’s a temporary workaround:

global $wp_version;
if ($wp_version == "2.8") wp_enqueue_script("thickbox28", "/wp-includes/js/thickbox/thickbox.js", array("jquery"));
else wp_enqueue_script("thickbox");

Hope this helps. And don’t forget to inject the thickbox CSS and javascript settings in the wp_head action.

Update: Thickbox loads in the footer section in WordPress 2.8, that should be right before the closing body tag. And yes, loads of themes are lacking the wp_footer() function call. So, forget about the workaround, fix your themes first.

The 1.2.9 update of Quick Flickr Widget included the fix above, so 1.2.10 reverts that fix back to the standard way, sorry for the hassle ;)

Related posts:

  1. Quick Flickr Widget: Empowered by Thickbox
  2. Using the jQuery Lightbox Plugin in WordPress
  3. Loading jQuery from a CDN in WordPress
  4. jQuery in WordPress: wp_enqueue_script
  5. jQuery Cycle: Pager and pagerAnchorBuilder

9 Responses to “Thickbox and jQuery in WordPress 2.8”

  1. I have same problem, in firefox, after update at 2.8.
    I’am trying to fix…

    • kovshenin (@kovshenin)

      It shouldn’t be a browser problem. Definitely something wrong with wp ;) Let me know when you solve this..

  2. David

    You’re right! My theme was not calling the wp_footer() function, so that’s why thickbox was not working… thanks!

    • kovshenin (@kovshenin)

      You’re welcome =)

  3. Niko

    saved my life with from being hours in rage!!!
    thank you

    • kovshenin (@kovshenin)

      You’re welcome Niko ;)

  4. Same problem here in WP 2.8.4 your code solved the issue.
    Only one thing: since version is 2.8.4 instead of 2.8 i’ve changed the if condition to match the “main” WP version

    if (strpos($wp_version,"2.8") !== false)
    
    • kovshenin (@kovshenin)

      Hey Dwight, look at the update, and just call wp_footer(), it’s not a bug at all …

Including pingbacks & trackbacks

  1. HOWTO/FIX: ThickBox and Wordpress 2.8 issues « Dumpster-fairy.com linked here on September 12, 2009 at 10:45 pm