Skip to content

Instantly share code, notes, and snippets.

@patric-boehner
Last active October 8, 2020 11:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patric-boehner/b023f646445636959598 to your computer and use it in GitHub Desktop.
Save patric-boehner/b023f646445636959598 to your computer and use it in GitHub Desktop.
Customize WordPress Gallery HTML Output

#Customize WordPress Gallery HTML Output


This snippet is for modifying the shortcode and output for Wordpress's built in gallery function HTML. Particularly to modify the stucture for use with the Salvattore & Featherlight jquery to creat a masonary gallery with lightbox as none of the wordpress plugins meet my need. The source of the function is a little out of date compared with the current function Wordpress is using to output the galleries, but meets my needs as I am stripping out most of the markup. Plus I can't seem to get the shortcode_atts assigned in the function to work but thats not a deal breaker. I've updated the php with my new function. Still not sure if this is the best way to go about this but it works well for my need.

I've also added a second if statment to create another modified gallery to create a homepage slideshow using the wordpress agllery function and add suport for the Responsiveslides Jquery plugin.

I am using a conditional statment to check if the post is home in the first statment and using the single-portfolio.php template in the second, that way i only modify the gallery conditionaly.

I am adding an encapselating div with the id="grid' data-columns" for use with Salvattore and the class="gallery-item" for each image in the gallery for use with Featherlight. The rest is handeled with jqery.

I still need to look into making this better but for the moment it works.


#Refrance:

Codex:

Notes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment