简体   繁体   English

Ghost筛选器帖子按标签=子弹名称

[英]Ghost filter posts by tag = slug name

I'm writing a theme and I want to get all post tagged with the slug of any specific page by default 我正在写一个主题,并且我想默认将所有帖子标记为任何特定页面的标签

like myblog/page1 will return all post taged page1 像myblog / page1一样,将返回所有标记了page1的帖子

when i do 当我做

{{#get "posts" filter="tags:page1" order="slug asc"}}
    {{#foreach posts}}
      <p>{{@number}}" </p>
    {{/foreach}}
{{/get}}

I get my post and everything is fine 我知道了,一切都很好

but when I add the #post context to get the tag dynamically it doesn't work 但是当我添加#post上下文以动态获取标签时,它不起作用

I have tried : 我努力了 :

{{#post}}
{{#get "posts" order="slug asc"}}
    {{#foreach posts}}
        {{#has tag=@slug}}
             <p>{{@number}}" </p>
        {{/has}}
    {{/foreach}}

{{/get}}
{{/post}}

and

{{#post}}
{{#get "posts" filter="tags:@slug" order="slug asc"}}
    {{#foreach posts}}
      <p>{{@number}}" </p>
    {{/foreach}}
{{/get}}
{{/post}}

without any success. 没有任何成功。

Any help would be appreciated 任何帮助,将不胜感激

Ok everyone, actually it's pretty simple 好的,大家,这很简单

{{#post}}
{{#get "posts" filter="tags:{{slug}}" order="slug asc"}}
    {{#foreach posts}}
      <p>{{@number}}" </p>
    {{/foreach}}
{{/get}}
{{/post}}

in the post context , use the slug of the post , only trick is to put handlebars inside handlebars 在帖子上下文中,使用帖子的子弹,唯一的技巧是将车把放在车把内

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM