How can I add unique accordion boxes to each product page?

Hi, I’m adding in new text boxes to my product page, but i want the content to be specific to that product only. As i am editing the template slides it is duplicating to all products. I know i can change the description, but i want to add accordion boxes (ingredients) and add more sub-titles that are unique to each product.

How would do i go about doing this? My store is; https://e2eb82-2.myshopify.com/products/fresh

Hello @Hund1256 ,

You can try to follow these steps:

  • Go to Online Store → Themes → Customize → Templates
  • Locate the product template file (e.g., product.liquid or similar) and click on it to edit.
  • To add accordion boxes: You can create a custom field in the Shopify admin for each product to store the accordion content. Then, within the product template, retrieve and display the content for that specific product using Liquid logic. Here’s an example:
{% if product.handle == 'product-handle' %}
  
    ### Ingredients
    
      {{ product.metafields.namespace.field_name }}
    

  

{% endif %}
  • To add additional sub-titles: You can use Shopify’s product tags to differentiate products and conditionally display sub-titles based on those tags. Here’s an example:
{% if product.tags contains 'unique_tag' %}
  ## Additional Sub-Title
{% endif %}
  • Save changes

Hope this can help. Let us know if you need any further support.

Ali Reviews team.

Hi,

Thank you so much for replying to me! This is great, i’m trying to add the code in but nothing working. I’ve added a custom liquid box within the template and added the code not worked. I’ve only recently moved over from Squarespace so just getting used to a different way of working. Here is a screenshot.

Hello @Hund1256

To add accordion boxes for ingredients and unique sub-titles to each product in Shopify, you can follow these steps:

1.Access your Shopify theme editor: From your Shopify admin, go to “Online Store” and click on “Themes.” Then, locate the theme you’re currently using and click on “Actions” > “Edit Code.”

2.Modify the product template: In the theme editor, find the product template file where you want to add the accordion boxes and sub-titles. Typically, the file is named “product.liquid” or “product-template.liquid.”

3.Add HTML structure for accordion boxes: Within the product template file, locate the area where you want the accordion boxes to appear. You can create an HTML structure using

elements and appropriate classes to style the accordion. Here’s an example:


### Ingredients

{{ product.metafields.your_namespace.ingredients }}

In this example, we assume you have a metafield namespace named “your_namespace” where the ingredients data is stored.

4.Add unique sub-titles: Similarly, you can add unique sub-titles using liquid code based on metafields. Here’s an example:

## {{ product.metafields.your_namespace.subtitle }}

In this example, “your_namespace” is the metafield namespace, and “subtitle” is the specific metafield for the sub-title.

5.Save and test: After making the necessary changes, save the file and preview your product pages to ensure that the accordion boxes and unique sub-titles are displayed correctly.

Remember to replace “your_namespace” with the actual namespace you have defined for your metafields, and adjust the code based on your desired styling and HTML structure.

Hello @Hund1256

To add accordion boxes for ingredients and unique sub-titles to each product in Shopify, you can follow these steps:

1.Access your Shopify theme editor: From your Shopify admin, go to “Online Store” and click on “Themes.” Then, locate the theme you’re currently using and click on “Actions” > “Edit Code.”

2.Modify the product template: In the theme editor, find the product template file where you want to add the accordion boxes and sub-titles. Typically, the file is named “product.liquid” or “product-template.liquid.”

3.Add HTML structure for accordion boxes: Within the product template file, locate the area where you want the accordion boxes to appear. You can create an HTML structure using

elements and appropriate classes to style the accordion. Here’s an example:

<div class="accordion">
<div class="accordion-item">
<h3 class="accordion-title">Ingredients</h3>
<div class="accordion-content">
{{ product.metafields.your_namespace.ingredients }}
</div>
</div>
</div>

In this example, we assume you have a metafield namespace named “your_namespace” where the ingredients data is stored.

4.Add unique sub-titles: Similarly, you can add unique sub-titles using liquid code based on metafields. Here’s an example:

<h2>{{ product.metafields.your_namespace.subtitle }}</h2>

In this example, “your_namespace” is the metafield namespace, and “subtitle” is the specific metafield for the sub-title.

5.Save and test: After making the necessary changes, save the file and preview your product pages to ensure that the accordion boxes and unique sub-titles are displayed correctly.

Remember to replace “your_namespace” with the actual namespace you have defined for your metafields, and adjust the code based on your desired styling and HTML structure.