【问题标题】:Get latest posts inside author looping在作者循环中获取最新帖子
【发布时间】:2018-08-28 00:38:55
【问题描述】:

我需要创建一个作者列表,其中包含作者信息以及他/她最近的 4 个帖子。我的设计会是这样的,

这是我在搜索谷歌和挖掘文档后的方法。

{{#get 'users' limit="all" include="count.posts,posts"}}
        {{#foreach users}}
            {{!-- user datas --}}
            {{name}} , {{bio}} // ... and so on

            {{!-- This user's posts --}}
            {{#foreach posts limit="3"}} 
                <a href="{{ url }}"> {{ title }} </a>
            {{/foreach}}

        {{/foreach}}
{{/get}}

我正在完美地获取用户数据,但无法获取个人用户的帖子,

{{#foreach posts limit="3"}} 
     <a href="{{ url }}"> {{ title }} </a>
{{/foreach}}

请纠正我。 谢谢。

【问题讨论】:

    标签: ghost-blog


    【解决方案1】:

    对任何给定作者的帖子试试这个:

    {{#get 'users' limit="all" include="count.posts,posts"}}
       {{#foreach users}}              
            {{#get "posts" filter="authors:{{slug}}" limit="3"}}          
                {{#foreach posts}}
                     <a href="{{url}}"> {{title}} </a>
                {{/foreach}}            
              {{/get}}
        {{/foreach}}
    {{/get}}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-12
      • 1970-01-01
      • 1970-01-01
      • 2016-12-17
      • 2010-11-24
      • 2019-08-24
      • 1970-01-01
      相关资源
      最近更新 更多