获取作者循环内的最新帖子

问题描述 投票:1回答:1

我需要创建一个作者列表,其中包含作者信息以及他/她最近的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个回答
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}}
© www.soinside.com 2019 - 2024. All rights reserved.