Custom URLs in Elementor Gallery

Introduction

This tutorial will guide you through adding custom URLs to individual images in an Elementor gallery without the need for extra plugins. It works seamlessly with both the Basic Gallery widget and the Pro Gallery widget, making it suitable for users of all skill levels. With this straightforward guide, you’ll quickly master adding custom URLs to your Elementor galleries.

By default, Elementor only allows you to open individual images in a lightbox or link all images to a single custom URL. However, with this tutorial, you’ll be able to add links to individual images in the gallery.

You can check out a working example featuring both types of Elementor galleries here:

Add Your Gallery Widget

Start by adding your gallery widget and including the required images on the page. You can customize the aspect ratio of your gallery images by following this tutorial. You have the option to use either the Basic Gallery Widget or the Pro Gallery Widget.

  

Assign a CSS Class Name to the Widget

Edit your gallery widget, then go to Advanced > Layout > CSS Classes, and insert your chosen class name. For this example, we’ll use “bb-gallery–links”.

Set Gallery Link Type

Modify the Gallery widget under Content > Link. 

For the Pro Gallery widget, set it to Custom URL.

For the Basic Gallery widget, set it to Media File.

Add a custom HTML Widget to the Page

We’ll use a custom JS snippet, so you can add an HTML widget to your page or use your preferred code snippets plugin. I like to use Elementor’s HTML widget.

Add Custom JS Snippet

Add this code to the HTML Element. Replace the links with your own.

				
					<script>
let bbGalleryLinks = (className, imgLinks, linkTitles) => {
    const galleryImages = document.querySelectorAll(className + " a");

    // Code to add links to gallery images
    for (let i = 0; i < imgLinks.length; i++) {
        if (imgLinks[i] !== "") {
            galleryImages[i].href = imgLinks[i];

            // Open link in new window
            // galleryImages[i].target = "_blank";

            // Additional loop to add aria-label to links for accessibility
            if (linkTitles[i] !== "") {
                galleryImages[i].setAttribute("aria-label", linkTitles[i]);
            } else {
                // Consider handling the case where linkTitles[i] is an empty string
                console.error("Link title is empty for image " + i);
            }
        }
    }
};
    </script>

document.addEventListener("DOMContentLoaded", function () {
    bbGalleryLinks(
        ".bb-gallery--links",
        [
            "https://www.benboonedoesit.com" ,
            "https://www.benboonedoesit.com" ,
            "https://www.benboonedoesit.com" ,
            "https://www.benboonedoesit.com" ,
        ],
        [
            "Benboonedoesit Home Page",
            "Benboonedoesit Home Page",
            "Benboonedoesit Home Page",
            "Benboonedoesit Home Page"
        ]
    );
				
			

Note:

The links work sequentially for each image in the gallery widget from left to right, top to bottom. If you want to skip any image in the sequence, simply add a blank “”.

If you Have Multiple Gallery Widgets

If you have multiple gallery widgets on your page, then you simply need to add a new class name e.g. bb-gallery2–links to your other gallery widget. Then, in your html widget, call the function bbGalleryLinks() again and pass in the new classname and links. As shown below

 

				
					 <script>
let bbGalleryLinks = (className, imgLinks, linkTitles) => {
    const galleryImages = document.querySelectorAll(className + " a");

    // Code to add links to gallery images
    for (let i = 0; i < imgLinks.length; i++) {
        if (imgLinks[i] !== "") {
            galleryImages[i].href = imgLinks[i];

            // Open link in new window
            // galleryImages[i].target = "_blank";

            // Additional loop to add aria-label to links for accessibility
            if (linkTitles[i] !== "") {
                galleryImages[i].setAttribute("aria-label", linkTitles[i]);
            } else {
                // Consider handling the case where linkTitles[i] is an empty string
                console.error("Link title is empty for image " + i);
            }
        }
    }
};

document.addEventListener("DOMContentLoaded", function () {
    // Add comments explaining the purpose of the code below

    // First Gallery Widget
    bbGalleryLinks(
        ".bb-gallery--links",
       [
"https://www.benboonedoesit.com",
"https://www.benboonedoesit.com",
"https://www.benboonedoesit.com",
"https://www.benboonedoesit.com"
        ],

         [
            "Benboonedoesit Home Page",
"Benboonedoesit Home Page",
"Benboonedoesit Home Page",
"Benboonedoesit Home Page”       
]

    );

    // Second Gallery Widget
    bbGalleryLinks(
        ".bb-gallery2--links",
        [
"https://www.benboonedoesit.com",
"https://www.benboonedoesit.com",
"https://www.benboonedoesit.com",
"https://www.benboonedoesit.com"
        ],
        [
            "Benboonedoesit Home Page",
"Benboonedoesit Home Page",
"Benboonedoesit Home Page",
"Benboonedoesit Home Page”       
 ]
    );
});

</script>

				
			

Share:

More Posts

Digital Marketing
Ben Boone

Page Speed: How to Evaluate and Improve It

Google has indicated that site speed (and as a result, page speed) is one of the signals used by its algorithm to rank pages. Research has shown that Google might specifically measure time to first byte when considering page speed.

Read More »

Marketing Operations

In Marketing Operations, I am dedicated to creating efficient workflows and maximizing the impact of each campaign through thoughtful automation and resource alignment. This includes managing platforms like HubSpot and integrating additional tools to create seamless, automated processes that support lead nurturing, customer journeys, and data collection.

Implementing automation systems is a particular area of pride, as I enjoy leveraging a range of tools to streamline repetitive tasks, enhance personalization, and improve team productivity. By automating key processes, I ensure that campaigns reach the right audiences at the right time with minimal manual intervention, allowing the marketing team to focus on strategic, creative work.

I also prioritize maintaining data health across platforms, regularly auditing data and enhancing reporting capabilities to provide actionable insights for leadership. Standardizing processes across campaigns is essential to my approach, as it establishes a clear framework for tracking performance metrics, optimizing ROI, and adapting quickly to new campaign goals.

Market Research

In Marketing Research, I dive deep into data to identify key trends, customer needs, and competitive insights that shape effective marketing strategies. Through techniques like audience segmentation, competitive analysis, and market trend tracking, I gather actionable insights that guide campaign planning and product positioning.

I have used a variety of tools to gather research to help guide my marketing campaigns. 

I use Google Analytics to gain insights into website traffic, user behavior, and conversion funnels, providing essential data for audience segmentation and content optimization. With SEMrush or Ahrefs, I analyze competitor strategies, perform keyword research, and track backlinks to identify content gaps and improve search performance. SimilarWeb helps me understand competitor traffic sources and audience demographics, while BuzzSumo allows me to monitor popular content across platforms and identify key influencers. For customer feedback, I leverage tools like SurveyMonkey or Mailchimp Surveys to gather direct insights. 

For consumer behavior and trend analysis, Google Trends enables me to track keyword popularity and seasonal fluctuations, and Statista offers valuable industry data and consumer survey results. Additionally, Think with Google provides insights into emerging digital marketing trends. To monitor brand mentions and sentiment, I utilize Hootsuite Insights and  Sprout Social for social listening, and Brandwatch to track sentiment and brand health.

When it comes to on-site user behavior, Hotjar offers heatmaps, visitor recordings, and surveys, while Mixpanel is invaluable for tracking user interactions and retention. For in-depth market data, Facebook Audience Insights in Ads Manager helps me analyze audience demographics, interests, and behaviors to fine-tune targeting. 

But, these are the just the names of the tools and what they do. Anyone can write that down. Campaigns have different needs and companies find different tools more useful than others. There is crossover here with tools, for sure. For example, I would probably use SEMrush or Ahrefs for SEO work or checking backlinks, not to find a clean source of data to report back to stakeholders with when they ask what type of customers are viewing the website. However, by using all these tools, I do glean a fuller, and more holistic view of the brand and its various data pools. Most importantly, I think it is valuable to know what data you can find, where. 


Content Strategy

In Content Strategy, I develop structured plans that ensure every piece of content—whether web, social, or email—serves a clear purpose and speaks to the right audience. I focus on creating cohesive messaging, optimizing content for SEO, and using data insights to refine and target each asset.

By understanding the customer journey and aligning content with business objectives, I help build brand visibility, nurture leads, and drive conversions. My approach ensures that all content works together to engage audiences and achieve measurable results.