I need the built-in gallery shortcode to output UL instead of DL. How can I do it? I know I can use the ‘post_gallery’ filter, but that means almost duplicating the media’s gallery_shortcode function. I’d like to find a less ‘verbose’ solution.
Thank you
You can use the the following attributes for the gallery shortcode:
The problem with this is that the gallery shortcode wraps the image and the caption in different elements(thats why the default solution is using dl-dt-dd), so this will generate one li element for the image, and one for the caption. You can still style it using CSS though, because both of the element has unique classnames.
Ok, so I rewrote the gallery shortcode function by copying the original and removing/adding/changing what I needed, and now I share it with you. The major things I added/changed are:
Here’s the code:
And just to complete the gallery shortcode “chapter”, here I show you how to eventually programmatically change the default and/or user defined attributes. Say for example I need to change the size attr based on number of items:
Hope it will help other people searching for a cleaner gallery markup.