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}}
Unfortunately at this moment this helper not supports random ordering – I will consider to add it for next release
--
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!
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…
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
--
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!