All things Shopify and commerce
I need to display three featured products on each collection page. I want these products for be specifically from that collection and not the same products displayed across all collection pages, which is all I have been able to create so far!
I can't work out how to create this so any advice appreciated.
Thanks
Hi,
This is Richard at PageFly - Shopify Advanced Page Builder app.
To display three featured products on each collection page that are specifically from that collection, you can use Liquid programming and Shopify's built-in features. Here's a step-by-step guide:
1. Create a Liquid Snippet:
2. Write the Liquid Code:
Paste the following code into the featured_products.liquid snippet:
{% if collection.products.size > 0 %} <h3>Featured Products</h3> <div class="featured-products"> {% for product in collection.products.limit(3) %} <div class="featured-product"> <a href="{{ product.url }}"> <img src="{{ product.images.first.url | img_url: 'small' }}" alt="{{ product.title }}"> </a> <h4><a href="{{ product.url }}">{{ product.title }}</a></h4> <p>{{ product.price | money }}</p> </div> {% endfor %} </div> {% endif %}
3. Add the Snippet to Your Collection Template:
{% include 'featured_products' %}
Hoping my solution helps you solve your problem.
Best regards,
Richard | PageFly
Please let me know if it works by giving it a Like or marking it as a solution!
➜ Optimize your Shopify store with PageFly Page Builder (Free plan available)
All features are available from Free plan. Live Chat Support is available 24/7.
Hi MTSport,
You might want to try creating a Meta-field for a featured products in the Collection
You’ll require Shopify Meta fields to store specific product information for each collection. Meta fields allow you to attach additional data to various parts of your store.
Navigate to your Shopify Admin panel.
Go to Settings > Custom data > Collections.
Open the collection.liquid file (or the template).
If you are using a section-based theme, look for collection-template.liquid or similar under Sections. CTRL+ F to find then you have to paste your custom code, if need be, seek help from an expert or ask your dev for guidance
Explanation:
Metafields allow you to store additional information about your collections (in this case, a list of featured products).
Liquid template changes let you pull that data and display it on the front end. The code dynamically checks if the metafield is set for the collection and displays the corresponding products.
You can reply here for further explanations and process break down.
Thanks for taking the time to read!
@MTSport To display three featured products in a collection page, please follow the below steps.
1. Go to "Settings" -> "Custom data" -> "Collections".
2. Add a metafield for the collection with product type.
3. Then, go to "Online Store" and click the action button from the current theme and then select "Edit code".
4. Create a new section with the reference of the featured-collection.liquid section. Use the created metafield values to display the products on the collection page.
5. Once created the section, design it as per your need.
Don't hesitate to reach us through mail for further assistance.
@MTSport Happy to hear that our solution was helpful for you. It would be helpful for others too, if you mark it as an "Accepted" solution and also support us by clicking "Like". Kindly don't hesitate to contact us for any other helps.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024