Lightbox2 doesn’t work in a WP theme

I am converting one of my static templates to WP. The static template made use of Lightbox2 by Lokesh (, so I wanted to keep it in a new version too.

I’ve imported the styles and scripts as following:

wp_enqueue_style( 'lightbox', get_template_directory_uri() . '/assets/plugins/lightbox/css/lightbox.css' );
wp_enqueue_script( 'lightbox', get_template_directory_uri() . '/assets/plugins/lightbox/js/lightbox.min.js' );

and it is loaded in the page header alright.Lightbox is initiated the following way:

<a href="" data-lightbox="gallery">
    <img src="" class="img-responsive" alt="Onion">

However it does’t work for some reason, opening an image in a new tab. There are also no JS erros in console. Anybody happened to run into the same issue?

Read more here: Lightbox2 doesn’t work in a WP theme

Leave a Reply

Your email address will not be published. Required fields are marked *