I'm trying to make a photo gallery page for all my photos in my post-gallery post and have a modal open when you click on the photos. In the page there will probably be almost 100 photos and i'm not sure how to do this in a good way without duplicating the code for the modal 100x. I have considered using plugins but i'd doing this as part of making my own website and learning developing wordpress themes so i'd prefer if the solution is done with code.
Something Best practice solution for this situation would be great!
I would appreciate tips in how to do this!
data
attribute to each image in the gallery likedata-img=""
and then for each image include it's ID or something else unique. Then when someone clicks on the image you grab the value of that attribute and use the unique identifier to tell the modal lightbox which image it should display. So to do this you have to be able to access/modify your 'gallery' output code. Then just include the modal script in your JS and you're all set.