【问题标题】:Exclude Articles From Blog Home Page if Article Contains Specific Tag?如果文章包含特定标签,则从博客主页中排除文章?
【发布时间】:2018-10-04 18:45:37
【问题描述】:

如果文章包含特定标签,我想在我们的博客主页上排除某些文章。例如,如果我访问https://example.com/blogs/sample-blog,我想排除所有包含“example-tag”标签的帖子。

如果我访问诸如https://example.com/blogs/sample-blog/tagged/example-tag 之类的标记网址,我仍然希望显示这些文章。

我在我们的博客模板中尝试了以下代码的变体,但没有任何效果。

{% unless article.tags contains 'example-tag' %}
    Code Here
{% endunless %}

有没有人对我如何让它发挥作用有任何想法?任何帮助将不胜感激!

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    尝试使用布尔变量:

    {% assign realtedTag = false %}  
    
    {% if article.tags contains 'example-tag' %} 
    {% assign realtedTag = true %} 
    {% endif%}
    
    {% if realtedTag == false %} 
     Show your article 
    {% endif%}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多