Skip to content

Instantly share code, notes, and snippets.

@mateusneves
Created July 16, 2014 21:01
Show Gist options
  • Save mateusneves/94c9e1f66b7dec2760d5 to your computer and use it in GitHub Desktop.
Save mateusneves/94c9e1f66b7dec2760d5 to your computer and use it in GitHub Desktop.
Add custom attributes to images links in the WordPress native gallery
add_filter('wp_get_attachment_link', 'add_gallery_id_rel');
function add_gallery_id_rel($link) {
global $post;
return str_replace('<a href', '<a class="fancybox" rel="gallery" href', $link);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment