Update November 21st, 2023: I’ve tested this script with WooCommerce 8.3.0, and it’s fully functional.
In the dynamic world of e-commerce, product attributes in WooCommerce play a pivotal role. By transforming these attributes into clickable links, we open doors to a more intuitive and informative shopping experience.
Understanding Product Attributes in WooCommerce
Product attributes are the backbone of product differentiation in WooCommerce. They can be global, used across multiple products, or local, specific to individual products. Understanding this distinction is key to effective product management. You can learn more about them in the WooCommerce documentation, but here is a quick guide:
You can create Global attributes from Products > Attributes, they are taxonomies, like product categories or post tags. Any product can use an attribute defined there, this is why they are global.
You can instead define Local attributes in the product, while creating/editing it, in the tab Attributes. They are available only on the product where they have been defined and not usable by other products.
The Advantages of Linkable Product Attributes
Making attributes linkable can significantly enhance your store’s usability and SEO. It allows customers to easily navigate and find products based on specific attributes, creating a more engaging user journey.
Making Product Attributes Linkable
Tailoring your WooCommerce store to include linkable attributes involves custom coding. This approach offers unparalleled flexibility, allowing you to create a unique and user-friendly shopping environment.
Because of the difference between the two types of attributes that we outlined earlier, we need to use two different ways to add a URL to the product attribute term.
Before implementing any code changes, always ensure your site is backed up. This will help you restore things in case of unforeseen errors. I recommend using Jetpack Backup for real-time backups and one-click restores.
Open your functions.php file in wp-content/themes/your-child-theme-name/ and add this code at the end of the file:
From line 2 to line 68, the code adds a field named URL in the form for creating and editing global attributes. The functions are to register the field, add it in the Add New term form, add it in the Edit term form and save the field.
From line 70 to the end of the file, it tweaks the values in the tab Additional Information in the single product page to handle the URL of the product attribute term. This function, also handles URLs for local attributes.
How to Use The Product Attribute URL
For global attributes, go to Products > Attributes and add a new attribute, or edit an existing one. It will appear in the table on the right. Click on the cogs icon to add product attribute terms in it, you will see this form:

As you can see, there’s a new field at the bottom of the form Add new Color (Color is the name of the attribute I used for this example), named URL. Write there the URL you want the product attribute term to link to.
The same field is available while editing the product attribute term:

For local attributes instead, we don’t have an interface like this, so we have to find a workaround to add URLs to product attribute terms.
Do not use this method for local attributes that are Used for Variations. The script is not meant to handle such cases. Use it only for attributes that are shown on the product page but not used for variations.
Did you know that I love Markdown? That is what we are going to use for local attributes, Markdown!
Edit a product from Products > All Products and open the Attributes tab. From here, add a new Custom product attribute. Then give it a name and add some values using Markdown to create links:
[Text shown](https://myurl.com)
This is the format to use. An example is shown in this screenshot:

The second attribute here, Test, is the local attribute.
Now click on Save Attributes and Publish your product. This is how it will appear on the website:

Enhancing Your Store with Linkable Attributes
Linkable product attributes not only enhance the functionality of your WooCommerce store but also enrich the customer experience. They are a testament to the flexibility and adaptability of WooCommerce as an e-commerce platform.
Have you tried making your product attributes linkable? Share your experiences and tips in the comments below.
Leave a Reply