Randomization of suggested CMS blog-post

Hi there,

Hope you can help. This is regarding custom code for my CMS “Blog post template”

I am trying to randomize my suggested CMS-blog posst, so the suggested blog posts underneath the blog currently being read are randomly picked instead of being the last 3 posts.

I used custom code I found in a guide, but unfortunaly it is not working. I suspect it is due to the class I am using.


<!-- Add to closing body -->
<script>
$.fn.shuffle = function() {
  $.each(this.get(), function(index, el) {
    var $el = $(el);
    var $find = $el.children();
    var i = $find.length, k , temp;
    
     while(--i > 0) {
        k = Math.floor(Math.random() * (i+1));
        temp = $find[k];
        $find[k] = $find[i];
        $find[i] = temp;
     }

    $el.empty();
    $find.appendTo($el);
  });
};

$( document ).ready(function() {
    $(".related-blogpost-list-2").shuffle();
});
</script>

Here is my site Read-Only: [Webflow - Under Åben Himmel][1]
([how to share your site Read-Only link][2])

[1]:
[2]: Share a read-only link | Webflow University

Why just don’t set the condition on the filter “not current blog” ?

On your blog page in the Andre blogindlæg section;
Set the sort order to random.

This will show 3 random blog posts, which are different from the current displayed post, and the randomization will update about every 12 hours.

image

Amazing, works thanks!