Check out the WordPress Plugin of lightGallery

Lightgallery methods

This is just a demonstration of how to use lightgallery methods. You can find more methods here

HTML structure

<div id="methods">
  <a href="img/img1.jpg">
      <img src="img/thumb1.jpg" />
  </a>
  <a href="img/img2.jpg">
      <img src="img/thumb2.jpg" />
  </a>
  ...
</div>

Javascript

var $methods = $('#methods');
var slide = '<a href="img/img2.jpg">' +
    '<img src="img/thumb2.jpg" />' +
'</a>';

$methods.lightGallery();
$('#appendSlide').on('click', function() {
    $methods.append(slide);
    $methods.data('lightGallery').destroy(true);
    $methods.lightGallery();
});