Sign in

getPostsByTags in Post page is possible?

  • This topic has 4 replies, 3 voices, and was last updated 3 years, 5 months ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2611
    Avatar photogpsblues

    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 photoVerhoeckx
    #2618
    Avatar photogpsblues

    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.

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

    #2661
    Avatar photogpsblues

    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!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘getPostsByTags in Post page is possible?’ is closed to new replies.