Sign in

Different Post ordering

  • This topic has 6 replies, 2 voices, and was last updated 10 months, 1 week ago by .
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #8809
    Avatar photoclac1

    I am building a site with menus to display posts related to a tag.
    I want to display the posts in a different order depending on the menu the visitor clicks on.
    Is there a way to implement this?
    Thanks in advance for your help!

    #8815
    Avatar photoBob

    It seems to me that the easiest way to do this would be just to display tag pages.
    For example, let’s say you have posts about dogs and cats:

    1. add to the menu two items: the dog and cat tag.
    2. these pages will now display all posts related to those tags.

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

    #8817
    Avatar photoclac1

    Of course, that’s what I did.
    But I would like to sort the posts related to cats in one way (e.g. on the date of publication) and those related to dogs on another criterion (e.g. by alphabetical order of titles).
    How do I do this?

    #8818
    Avatar photoBob

    By default, it’s not possible. But I think you can create dedicated tag-templates for dog and cat categories with the getPostsByTags helper.

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

    #8820
    Avatar photoclac1

    It seems to be a good solution. can you guide me on how to implement it, please? I am not a developer…

    <p class=”simple-translate-result” dir=”auto”></p>
    <p class=”simple-translate-candidate” dir=”auto”></p>

    #8821
    Avatar photoBob

    I don’t have enough free time to present a complete solution, so I recommend reading the following articles:

    1. Creating custom tag template https://getpublii.com/dev/how-to-create-custom-templates/#customtagtemplates
    2. Get posts by tag helper: https://getpublii.com/dev/getpostsbytags-helper/

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

    #8825
    Avatar photoclac1

    Here is what I made.

    1. create editorial-2-override directory
    2. copy config.json in it
    3. Add in it:
      “tagTemplates”: {
      “TEMPLATE_SLUG”: “Tri des tags par libelle”
      },
    4. choose
    5. create tag-TEMPLATE_SLUG.hbs file in the same directory by copy of tag.hbs
    6. I tried many places for the following code, without success:
      {{#getPostsByTags “count=-1&allowed=hidden,featured&tag_as=id&tags=10&orderby=modifiedAt&ordering=desc”}}
      {{/getPostsByTags}}

    I definitely don’t understand how to embed this code in the tag.hbs page… Any help will be very appreciated. Thanks in advance.

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