Sign in

Get Posts by Tags Querystring Operators

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3659
    stephenfsnowstephenfsnow

    I’m trying to get posts by a specific combination of tags and I’m wondering if the querystring in the #GetPostsbyTags helper can accept operators in some way? For example I have posts with the tag About and some with the tag City but want to only display posts that contain About AND City filtering out any posts that contain only one of the tags. I attempted to achieve this using the {{#checkIf}} method of getting posts by specific tags but nesting the {{#checkIf}} helper doesn’t seem to work such as in the example below…

    {{#each @website.contentStructure.tags}}
      {{#checkIf this.name '==' 'About'}}
        {{#checkIf this.name '==' 'City'}}
          {{#each this.posts}}
            {{text}}
          {{/each}}
        {{/checkIf}}
      {{/checkIf}}
    {{/each}}

    Any help is appreciated!

    #3662
    Tomasz DziudaTomasz Dziuda
    Moderator

    Hi,

    Unfortunately it is not possible at this moment with getpostsbytags but I see if it is easily possible to add an operator param which will allow OR and AND values to solve your issues, because it is a good idea 🙂

    --
    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!

    #3663
    Tomasz DziudaTomasz Dziuda
    Moderator

    Related issue https://github.com/GetPublii/Publii/issues/806

    --
    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!

    #3695
    stephenfsnowstephenfsnow

    Awesome! Excited to see this feature in a future release, thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.