Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jekyll 杰基尔。如何按类别过滤除当前帖子外的最近帖子?_Jekyll_Liquid_Jekyll Extensions - Fatal编程技术网

Jekyll 杰基尔。如何按类别过滤除当前帖子外的最近帖子?

Jekyll 杰基尔。如何按类别过滤除当前帖子外的最近帖子?,jekyll,liquid,jekyll-extensions,Jekyll,Liquid,Jekyll Extensions,我想在一个页面上按类别获取最后3篇文章,除了此过滤器中的当前页面 我的代码不起作用: {% for cat in page.categories[0] %} {% for post in site.categories[cat] limit: 3 %} {% if post.title == page.title %} {% break %} {% endif %} <div class="item">

我想在一个页面上按类别获取最后3篇文章,除了此过滤器中的当前页面

我的代码不起作用:

{% for cat in page.categories[0] %}
    {% for post in site.categories[cat] limit: 3 %}
        {% if post.title == page.title %}
            {% break %}
        {% endif %}
      <div class="item">
        <a href="{{ post.url | relative_url }}">
            <div class="image" style="background-image: url({{ post.image }});"></div>
            <div class="item-text main">
                <h1>{{ post.title }}</h1>
            </div>
        </a>
      </div>
    {% endfor %}
{% endfor %}
{%用于页面中的cat。类别[0]}
{站点中的帖子的百分比。类别[cat]限制:3%}
{%if post.title==page.title%}
{%break%}
{%endif%}
{%endfor%}
{%endfor%}
您可以替换

{%if post.title==page.title%}
{%break%}
{%endif%}

{%除非post.url==page.url%}

完整代码

{% for cat in page.categories[0] %}
{% for post in site.categories[cat] limit: 3 %}
    {% unless post.url == page.url %}
  <div class="item">
    <a href="{{ post.url | relative_url }}">
        <div class="image" style="background-image: url({{ post.image }});"> 
        </div>
        <div class="item-text main">
            <h1>{{ post.title }}</h1>
        </div>
    </a>
  </div>
 {% endunless %}    
{% endfor %}
{% endfor %}
{%用于页面中的cat。类别[0]}
{站点中的帖子的百分比。类别[cat]限制:3%}
{%除非post.url==page.url%}
{%end除非%}
{%endfor%}
{%endfor%}