首页 > 解决方案 > Ghost:在 foreach 循环中获取帖子的 URL

问题描述

我正在寻找使用{{#foreach posts}}{{/foreach}}帮助程序访问的帖子的 URL。我现在使用的结构是:

            <div class="pfdflxbx">            
                {{#get "posts" limit="3" include="tags, authors" filter="featured:true"}}
                    {{#foreach posts limit="3"}}
                        {{title}}
                    {{/foreach}}
                {{/get}}
            </div>

当我在和之间插入{{url}}助手时,返回给我的 URL 是网站主页的 url。{{title}}{{/foreach}}

如果我使用以下结构:

            <div class="pfdflxbx">            
                {{#get "posts" limit="3" include="tags, authors" filter="featured:true"}}
                    {{#foreach posts limit="3"}}
                    {{#post}}
                        {{title}}
                    {{/post}}
                    {{/foreach}}
                {{/get}}
            </div>

没有任何东西呈现给 DOM,例如,没有帖子填充。

有人可以帮助阐明这里的正确做法吗?

标签: ghost-blog

解决方案


我发布的第一个解决方案是正确的。我正在使用的后端版本中存在一个错误,导致博客帖子的 URL 重定向到欢迎页面。


推荐阅读