Created
June 20, 2022 01:05
-
-
Save hezninja/edd959488a5a66520bb46c74c6a0283a to your computer and use it in GitHub Desktop.
Shopify blog sub-menu using tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Create a sub-menu for the blog based on specific tags, grouped by a prefix. | |
Example menu: "Yamaha | Suzuki | Harley-Davidson etc" | |
Method: Tag a blog post with "specificPrefix_Yamaha" | |
--> | |
{% assign brandedBlogTagList = '' %} | |
{% for blogTag in blog.all_tags %} | |
{% if blogTag contains "specificPrefix_" %} | |
{% assign brandedBlogTagList = brandedBlogTagList | append: ',' | append: blogTag %} | |
{% endif %} | |
{% endfor %} | |
{% assign brandedBlogTagList = brandedBlogTagList | remove_first: ',' | split: ',' %} | |
{% for brand in brandedBlogTagList %} | |
<a href="/blogs/blog/tagged/{{ brand | handleize }}">{{ brand | split: 'specificPrefix__' | last }}</a> | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment