Get Blog Post by Handle in Shopify Liquid

Posted 4 months ago     548      shopify liquid

Get Blog Post by Handle in Shopify Liquid with a page include as a fallback.

In my example below, there's the blog called sizing and sizing_chart variable is the post.


{% assign sizing_cart = 'this-is-my-post-handle' %} {% assign found = false %} {% for sizes in blogs['sizing'].articles %} {% if sizes.title == sizing_cart %} {% assign found = true %} {{ sizes.content }} {% endif %} {% endfor %} {% if found == false %} {%- include 'sizing-template-hardcoded' -%} {% endif %}

Comments

There are no comments yet.

You need to be logged in to post comments.



Welcome to Snippet Repo!

Discover, share and save useful code snippets.

Join our community over over 2,000 members! Currently a 48% acceptance rate. Apply for membership →