Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I am working on displaying products on blog posts and have managed to get a single product to display.
Is there a way to get all products to display?
The code I'm using: (It looks at the tags in blog post, finds the one containing product_[product name] and displays it.
{%- liquid
for tag in article.tags
if tag contains "product_"
assign prod_handle = tag | split: "_"
assign blog_prod = all_products[prod_handle[1]]
endif
endfor
%}
{% if blog_prod %}
<h2>Recommended solutions</h2>
<div class="boost-pfs-filter-products boost-pfs-filter-product-item-label-type-rectangle boost-pfs-filter-product-item-label-has-border boost-pfs-filter-product-item-show-details-false boost-pfs-filter-product-item-layout-border-no-padding boost-pfs-filter-product-item-label-top_left boost-pfs-filter-product-item-swatch_color_display_type_image_product boost-pfs-filter-swatch-shape-circle boost-pfs-filter-product-item-text-alignment-left">
{% include 'use-case-product-grid-item' %}
</div>
{% endif %}
Hi @JoshSpires
I understood your concern. I came to know that you can achieve it using custom code.
Please add the below code to the file
{% assign allhandles =''%}
{%- liquid
for tag in article.tags
if tag contains "product_"
assign prod_handle = tag | split: "_"
assign blog_prod = prod_handle[1]
assign allhandles = allhandles | append: ',' | append: blog_prod
endif
endfor
%}
{% assign newTagList = allhandles | remove_first: ',' | split: ',' %}
{%- for tag in newTagList -%}
{%- assign product = all_products[tag] -%}
{%- include 'product-grid-item' -%}
{%- endfor -%}
I hope it's helpful to you.
If you want a way to display products in a blog post just using the normal blog editor, I made an app that lets you embed multiple products into your posts.
https://apps.shopify.com/product-embed
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025