Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #224648

    Hi,

    I downloaded 2 plugins to add a link to an image in a gallery. Both times Enfold kept on showing the lightbox image. WP Gallery Custom Links and RPS Image Gallery where the plugins. Does anyone know if Enfold works with these plugins?

    Regards,

    David

    #224832

    Hey David!

    Make sure that you use the latest version of Enfold 2.5.2 because otherwise you can’t add a link to your gallery images. Then install this plugin http://wordpress.org/plugins/wp-gallery-custom-links/ and insert this code:

    
    add_filter('avf_avia_builder_gallery_image_link', 'avia_change_gallery_thumbnail_link', 10, 4);
    function avia_change_gallery_thumbnail_link($link, $attachment, $atts, $meta)
    {
        $custom_url = get_post_meta($attachment->ID, '_gallery_link_url', true);
        if(!empty($custom_url))
        {
            $link[0] = $custom_url;
            $link['custom_link_class'] = 'aviaopeninbrowser';
        }
        return $link;
    }
    

    into your child theme functions.php file (at the very bottom).
    Best regards,
    Peter

    #224850

    Hi Peter,

    I use the latest Enfold’s version. Your code creates an error when I copy paste it in functions.php:

    Parse error: syntax error, unexpected T_FUNCTION in /home/wineengratisvakantie.nl/public_html/redline/wp-content/themes/enfold/functions.php on line 470

    Regards,

    David

    #225309

    Hi David!

    Can you paste your full functions.php file in a Gist?

    Best regards,
    Josue

    #225411
    This reply has been marked as private.
    #225412

    It’s the functions.php file, not the functions-enfold.php file…

    #225576

    Hey!

    Did you install the plugin before adding the code?
    http://wordpress.org/plugins/wp-gallery-custom-links/

    Regards,
    Josue

    #225706

    Yes, but I might have deactivated it because I downloaded another plugin for adding links to a gallery. Shall I remove the plugin, install it again and than add the code to functions.php?

    Regards,

    David

    #225935

    Hi!

    You should use the WP Gallery Custom Links plugin. Add Dude’s code at the very bottom of functions.php. Make sure you have the latest version of Enfold.

    add_filter('avf_avia_builder_gallery_image_link', 'avia_change_gallery_thumbnail_link', 10, 4);
    function avia_change_gallery_thumbnail_link($link, $attachment, $atts, $meta)
    {
        $custom_url = get_post_meta($attachment->ID, '_gallery_link_url', true);
        if(!empty($custom_url))
        {
            $link[0] = $custom_url;
            $link['custom_link_class'] = 'aviaopeninbrowser';
        }
        return $link;
    }

    This works on our end. As you can see on the screenshot the link of the hovered image is google.com, which is the url that we set for the image.

    Cheers!
    Ismael

    #226097

    I remove and reinstalled the plugin and added your code. And gues what… it works!

    Thanks dude. :-)

    Regards,

    David

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘adding links to a gallery’ is closed to new replies.