Skip to main content
1 of 4
Ruslan
  • 103
  • 1
  • 4

Add gallery id to rel attribe of wp_get_attachment_link

Now i have this snippet in my functions.php

/**
 * Add rel to links.
 */
function add_rel_to_gallery($link) {
    return str_replace('<a href=', '<a data-fancybox="true" rel="group" href=', $link);
}
add_filter( 'wp_get_attachment_link', 'add_rel_to_gallery' );

Every link in gallery has rel="group", but actually i want get something like that:

rel="group-$gallery-id"

How do this?

Ruslan
  • 103
  • 1
  • 4