WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: Lightbox 2] Prevent Plugin Loading

[Resolved] [Plugin: Lightbox 2] Prevent Plugin Loading

  • Is there some way to prevent Lightbox 2 from loading on a frontpage?
    I have jCarousel Lite working on the frontpage and Lightbox 2 kills all functionality in the slideshow. What I don’t have on the frontpage is images in need of Lightbox.

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Anyone? I’m still looking for a solution.

    mattapus
    Member

    @mattapus

    Here is how I managed to solve this problem. Note that the example below only disables Lightbox on one post/page. To do so on multiple posts, you’ll have to mess around with the code a bit. Just replace “$pid = 240” with the post ID of your home page.

    In functions.php in your active theme directory, add the following:

    // Remove lightbox action
    //wp_deregister_script('lightbox');
    function mytheme_remove_lightbox_js() {
      $pid = 240; // This is the post/page id you would like to disable lightbox on
      global $wp_query; // Call page query object
      if ($wp_query->post->ID == $pid) {
        // Remove lightbox scripts
        wp_deregister_script('lightbox');
        remove_action('wp_head', 'lightbox_styles');
      }
    }
    add_action( 'wp_print_scripts', 'mytheme_remove_lightbox_js', 100 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] [Plugin: Lightbox 2] Prevent Plugin Loading’ is closed to new replies.