I am looking to use the WordPress gallery shortcut but I want to tie the output into the Foundation Orbit plugin (to make a slider). This is the HTML I am looking to output:
<div class="slideshow-wrapper">
<div class="preloader"></div>
<ul data-orbit>
<li>
<img src="img1.png" alt="bla bla bla" />
</li>
<li>
<img src="img2.png" alt="bla bla bla" />
</li>
<li>
<img src="img3.png" alt="bla bla bla" />
</li>
<li>
<img src="img4.png" alt="bla bla bla" />
</li>
</ul>
</div>
Is it possible to put something in functions.php
(or similar) to achieve this?
Yes, indeed. Quite a while ago I’ve found this code and have been using it ever since. It’s great to customize WP’s default gallery to whatever you want.
There’s a filter to
post_gallery
which you can use to customize all default WP galleries. Here’s a sample of the code I use adapted to the template you provided. I’ve cleared it up as much as possible.The first part of the function is pretty much gallery attachments handling, so you’ll probably just want to change the latter half, the one that determines the output of your gallery template (follow the comments):
Just paste it to your
functions.php
file and modify to adapt it to your need. I’m pretty sure it’ll work for you as it have worked for me 🙂Super answer Mathielo.
However, I needed the option of including a caption, so I’ve modified your code to use the wp_prepare_attachment_for_js() function as that seems to provide the necessary data.
I know the original question has been answered but I just wanted to share what I’ve done with the filter snippet in case it helps anyone else. I’ve enabled Miro Mannino’s ‘Justified Gallery’ jquery plugin http://miromannino.com/projects/justified-gallery/ to work with WordPress galleries in WordPress 3.9 … Here’s the code with the changes I made to get it to work… (img size light thumb is my custom thumbnail to preserve image dimensions but keep page load times down.)
It works a treat. Thanks for sharing the filter – it was just what I was looking for.
So if you want output another string like img title or img desc just use this construction
$title = $img[‘title’];
This is comment to Super answer Mathielo (second answer), and this universal solution, not only zubr foundation
Little note! If not disabled in admin area, this filter will cause gallery not to be visible in admin area. To avoid this, we can run filters main part inside if statement