在作者循环中获取最新帖子
Get latest posts inside author looping
我需要创建一个作者列表,其中包含作者信息以及 his/her 最近的 4 篇文章。我的设计将是这样的,
这是我搜索 google 并深入研究文档后的方法。
{{#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}}
请指正。
谢谢
对任何给定作者的帖子试试这个:
{{#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}}
我需要创建一个作者列表,其中包含作者信息以及 his/her 最近的 4 篇文章。我的设计将是这样的,
这是我搜索 google 并深入研究文档后的方法。
{{#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}}
请指正。 谢谢
对任何给定作者的帖子试试这个:
{{#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}}