[resolved] [Plugin: Lightbox 2] Prevent Plugin Loading (3 posts)

  1. Indent
    Posted 6 years ago #

    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!

  2. Indent
    Posted 6 years ago #

    Anyone? I'm still looking for a solution.

  3. mattapus
    Posted 5 years ago #

    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
    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
        remove_action('wp_head', 'lightbox_styles');
    add_action( 'wp_print_scripts', 'mytheme_remove_lightbox_js', 100 );

Topic Closed

This topic has been closed to new replies.

About this Topic