• Hi… I have a site that has the Lightbox Plus Colorbox plugin and the WP Gallery Custom Links plugin. My goal was to make the images in a gallery link to pages through a lightbox. The images are files uploaded through WP’s media tools and the galleries are made through WP’s shortcodes. The pages linked are custom post types.

    In order to make it work, I had to modify my functions.php file (well, I created a new one in my child theme) so that all images in a gallery were marked as class=”lbp_secondary”. I found this solution in another thread.

    add_filter('wp_get_attachment_link', 'add_gallery_id_rel');
    function add_gallery_id_rel($link) {
    	global $post;
    	if ( ($post->ID) == '175')
    		return str_replace('<a href', '<a class="lbp_secondary" href', $link);
    	else
    		return str_replace('<a href', '<a class="dummy" href', $link);
    }

    My problem is that EVERY image in EVERY gallery on that page opens a lightbox, and I only wanted a specific set to do so.

    Is there a way to specify in the functions.php code that only the images in a specific gallery, or links that point to a specific post-type (since the pages linked are a custom post type) will add that class to it? I am not familiar with PHP or how to work that kind of conditional in to the code.

    Please help, thanks!

  • The topic ‘How do I modify the images' class in a specific gallery?’ is closed to new replies.