简体   繁体   中英

Shopify / Liquid - Access articles outside of current tag search/filter

I have a Shopify blog, in this example called blog1 . I would like to use liquid to access all articles within that blog, whilst filtering by a specific tag.

For instance, supposing I am at the following URL (ie tagging by articles with the tag "chicken").

www.website.com/blogs/blog1/tagged/chicken

When I do {% for article in blog.articles %}{{ article.title }}{% endfor %} , it only outputs articles which have the tag "chicken". I understand that this is normal and expected behaviour for filtering, but I want to know how I can still somehow loop through all articles from this page.

I have looked at Shopify: blog.articles doesn't show all articles when in tagged view but their question is slightly different, and the only answer is not a valid solution in this case: {% for article in blog['blog1'].articles %}{{article.url}}{%endfor%} does not work.

You need to refer to the global blogs object and the specific handle of the blog.

So the answer you showed is correct but your implementation is not. The global blogs object is written like so blogs['handle'] and not blog['handle'] .

So in your case it will be like so:

{% for article in blogs['blog1'].articles %}
  {{article.url}}
{% endfor %} 

Just add the missing s in the blog object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM