Skip to content Skip to sidebar Skip to footer

Easy ways to create a responsive widget for random blog posts

How to create a random post on a blog – There are a lot of random postscripts on the website or blog I browsed that can be reused but are no longer active. So here I am going to share the latest script from Random Post.

Before installing the random post widget code, you can see the demo next to my blog.

To install the Random Posts widget on Blogger:

1. Go to “Layout”> “Add Widget / Add Widget”> select “HTML / Javascript”

2. First enter the widget title with “Random Posts” (up to you)

3. Copy and paste the random post script code below and copy and paste the code into the previous widget.



// Random Post Widget
var homePage=”“,
maxResults = 10,
containerId = ‘arlina-random’;
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max – min + 1)) + min;
function shuffleArray(arr) {
var i = arr.length, j, temp;
if (i === 0) return false;
while (–i) {
j = Math.floor(Math.random() * (i + 1));
temp = arr[i];
arr[i] = arr[j];
arr[j] = Temps;
back arr;
Function ArlinaRandomPosts (json) {
var startIndex = getRandomInt (1, (json.feed.openSearch $ totalResults. $ t – maxResults));
// console.log (‘Get the post feed start from’ + startIndex + ‘to’ + (startIndex + maxResults));
document.write (‘‘);
Function randomPosts (json) {
var link, ct = document.getElementById (containerId),
Entry = shuffleArray (json.feed.entry),
Skeleton = “
for (var i = 0, len = entry.length; i
for (var j = 0, jen = entry[i].link.length; j
link = (entry[i].Shortcut[j].rel == “alternative”)? entry[i].Shortcut[j].href: ‘#’;
Skeleton + = ‘
  • ‘+ Entry[i].title. $ t + ‘
  • ‘;
    ct.innerHTML = skeleton + ‘‘;
    document.write (‘‘);

    4. Change color Red with the name of your blog and how many posts you would like to appear in the random post.

    5. When you have followed the steps above, just save and save the template. See the result 🙂 Fast loading and responsive.

    Thank you for visiting the article Easy ways to create a responsive widget for random posts on blogger. Don’t forget to subscribe to us and share with your friends who need it.


    Just an ordinary person who wants to share their knowledge of games with the wider community.

    Post a Comment for "Easy ways to create a responsive widget for random blog posts"