• Hi there guys,

    I wonder if there is a way to add function only to widgets.

    I was planning using blueimp lightbox for my images, but since it includes all images from the page into the same lightbox I wanted to split images from widgets and images from page/post

    I used this code

    function add_rel_to_gallery($link) {
    return str_replace('<a href=', '<a data-gallery="#blueimp-gallery-test" href=', $link);
    }
    add_filter( 'wp_get_attachment_link', 'add_rel_to_gallery' );

    to add the data attribute to media links, well that works, but can you add this function only to widget areas or only to posts and pages?

The topic ‘Function only for widgets (lightbox data attribute)’ is closed to new replies.