$(document).ready( function() { $(".wp-block-gallery").children().each( function() { $(this).attr("data-lightbox", "gallery"); console.log(this) }); });