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.

Show random posts

  • #10437
    Avatar photo[anonymous]

    I would like to add a list of links with random posts on my website. But only posts with certain tags should be considered. With “getPostsByTags” I get the posts back correctly.

    Is there a way to sort them randomly now? Note: By random I don’t mean dynamically on the web page. It is enough if it is randomly sorted on each export.

    Thanks a lot!

    {{#getPostsByTags "count=100&&tag_as=id&tags=7"}}
    
    {{ title }}
    
    {{/getPostsByTags}}
    #10506
    Avatar photo[anonymous]

    Hi,

    Unfortunately at this moment this helper not supports random ordering – I will consider to add it for next release

    #10513
    Avatar photo[anonymous]

    Thank you very much! This is great.

    #10516
    Avatar photo[anonymous]

    I’d love to also be able to click on a menu item to go to a random post every time the button is clicked, kind of like how tumblr does it. I wonder if that’s possible already…

    #10518
    Avatar photo[anonymous]

    @candidexmedia – it is a possible solution which I have prepared with ChatGPT: https://chat.openai.com/share/f9384d04-be55-4091-836a-1bc8d49142a0 🙂

    My prompt is below in case if this link would expire in the future:

    Please prepare a JavaScript script, which will work in the following way:

    When user will click a link with `#random` set as `href` attribute:
    – add class “is-loading” to the clicked link
    – please retrieve the sitemap.xml file from the website domain (you can assume that sitemap.xml file is always in the root directory of the domain)
    – get a list of subpages from the sitemap
    – remove from the list subpages listed on the blacklist array
    – pick a random list element from the left items
    – redirect user to the selected random item

    #10916
    Avatar photo[anonymous]

    In the “get-posts-by-tags.js” file there is now “random” as the value for sorting. But not yet in the documentation.

    There was nothing about this in the blog entry for the last version.

    In any case, thanks for that. Works perfectly for me. 👍