Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

getPostsByTags in Post page is possible?

  • #2611
    Avatar photo[anonymous]

    I would like to show a specific list of posts within an article.
    Something like that:

    {{#getPostsByTags "tag_as=id&tags=1,2,3}} 
        <h4>{{ title }}</h4> 
    {{/getPostsByTags}}

    but in a Post page doesn’t work.

    Is there a method to do this?

    Thank you.

    #2612
    Avatar photo[anonymous]
    #2618
    Avatar photo[anonymous]

    Thank you @Verhoeckx,

    but it’s not the solution I’m looking for.

    I’m trying to access the much more flexible and powerful {{#getsPostsByTags}} helper. This inside post.hbs file. {{getsPostsByTags}} helper allows you to manage many more parameters such as multiple tags.

    What I’m trying to get is a “post” similar to the Mercury home page, but it’s a post not a front page.

    I have tried two ways:

    1. Mark the posts that I want to display as “featured” and access them with {{#each featuredPosts}}. It’s not an elegant method, but it works. The problem is that I “waste” the featured post function.
      This is the result, is a post page that shows posts from some specific categories:
      https://www.mywebpassion.it/siti/bw/portfolio/
    2. Use global variable {{#each @website.contentStructure.posts}} but managing multiple tags becomes very complicated.
    #2620
    Avatar photoBob

    {{#getsPostsByTags}} works very well on the post pages. I suppose that you are trying to use this helper by adding it with the post editor, and this way it will not work. Just add your code to the post.hbs file and I’m sure it will work.

    #2661
    Avatar photo[anonymous]

    Hi @Bob,
    thank you for your reply.

    Obviously I edited the post.hbs file…

    🙂

    but I have found that the count parameter is required!!!

    {{#getPostsByTags “count=-1&tag_as=id&tags=1,2,3″}}
    {{ title }}<br>
    {{/getPostsByTags}}

    Problem solved!