Tip: Add a rel attribute to WordPress gallery for lightbox use
Posted on This might be outdated!
This is really simple trick, but it’s so useful. I’m using lightboxes nearly on every WordPress project. I really love colorbox and prettyPhoto, they are my favorite. So when i create a gallery from the wordpress admin editor i want my gallery thumbnails to open in a lightbox, here is a bit of code to do it automatically:
Just paste this code in the functions.php file in your theme directory;
Nice tip. Often wondered that, thanks, that’ll be getting added to all my wordpress sites!
You’re welcome Simon!
Thanks for the great tip. Works like a charm when using a single gallery on a page.
Do you have any tips for adding a different rel value to a custom image size (add_image_size). Using your code works great for listing a single gallery on a page. If for example I used the the gallery shortcode (listing a different set of images) in a footer widget it’s causing all gallery thumbnails on the entire page (from the the widgets gallery and the page gallery) to appear in each gallery.
Awesome tips. Working great on my site. Thank you so much
[…] may need to refer to a code snip like this to get gallery integration though, once you’ve done the […]