• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Home
  • Blog
  • Sample Page

WordPress Tips

Just another WordPress site

Filtering the Gallery Image Output in WordPress – Adding Class or Data Attribute

July 10, 2016 Leave a Comment 3

WP Beaches ~

To manipulate the linked images, specifically the links themselves in the WordPress Gallery output for doing things like adding in a CSS class or a data attribute value you can use the post_gallery filter in /wp-includes/media.php which is the right tool for the job.

The filter can be applied like so…

View this code snippet on GitHub.

So this is an

Filed Under: data_attribute, filter, post_gallery, WordPress, wp_attachment_image, wp_attachment_link, wp_attachment_url Tagged With: data_attribute, filter, post_gallery, WordPress, wp_attachment_image, wp_attachment_link, wp_attachment_url

Reader Interactions

Related Posts

  • Media Temple Managed WordPress Hosting: Overview and Review
  • Hotjar Heatmap Analytics: An Overview and Review
  • How to Use a Heatmap to Improve Your Website’s Overall Quality
  • GreenGeeks Eco-Friendly Hosting: An Overview and Review

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Copyright ©2019 · WPress.Tips - All Rights Are Reserved · Powered by Genesis Framework