ghost-blog

Ghost: newest post with specific tag on the front page

我是研究僧i 提交于 2019-11-30 05:34:21
问题 I am developing a Ghost template for my blog. And I want to see on the front page only one newest post from posts with specific tag (eg "news"). Is it possible to filter posts by tag in foreach loop? Any other solution? (the first thing that comes to mind is some trick with custom template tag-news.hbs and URL rewriting) 回答1: You can definitely filter posts by tag using the {{has}} helper: {{#foreach posts}} {{#has tag="news"}} {{> post}} {{/has}} {{/foreach}} You could add this code to a