How to Add Random Posts Thumbnails Widget For Blogger Blogs

To Get your visitors engage more on your blogs, you need to add related posts or random post widget. In this post we are to know how to add random posts thumbnails widget for blogger blogs.

Random posts thumbnail widget has images thumbnail by the left and it displays the date and numbers of comments on a post. The random posts thumbnails widgets works in such a way that it pick your blog post randomly irrespective of the day, month or year being posted making your blog readers dig deep into old posts without making more efforts using labels or archive.

Also Read 4 Tools To Test Your Website Loading Speed.


How to Add Random Posts Thumbnails Widget For Blogger Blogs

Random Posts Thumbnails Widgets


1. Go To Blogger.com

2. Select the preferred blog to add the random Posts Thumbnails widget

3. Go to Layout and click Add a Gadget

4. Copy the Code below and paste it into the Widget

<style>
#random-posts img {
    float: left;
    margin-right: 10px;
    width: 65px;
    height: 65px;
    background-color: #F5F5F5;
    padding: 3px;
}
ul#random-posts {    list-style-type: none;}
#random-posts li {
    margin-bottom: 10px;
}
.random-summary {
    display: block;
}
</style>
<ul id='random-posts'>
<script type='text/javaScript'>
var randomposts_number = 10;
var randomposts_chars = 60;
var randomposts_details = 'yes';
randomposts_details2 = 'no';
var randomposts_comments = 'Comments';
var randomposts_commentsd = 'Comments Disabled';
var randomposts_current = [];
var total_randomposts = 0;
var randomposts_current = new Array(randomposts_number);
function randomposts(json) {    total_randomposts = json.feed.openSearch$totalResults.$t
}
document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=randomposts\"><\/script>');
function getvalue() {
    for (var i = 0; i < randomposts_number; i++) {
        var found = false;
        var rndValue = get_random();
        for (var j = 0; j < randomposts_current.length; j++) {
            if (randomposts_current[j] == rndValue) {
                found = true;
                break
            }
        };
        if (found) {
            i--
        } else {
            randomposts_current[i] = rndValue
        }
    }
};
function get_random() {
    var ranNum = 1 + Math.round(Math.random() * (total_randomposts - 1));
    return ranNum
};
</script>
<script type='text/javaScript'>
function random_posts(json) {
    for (var i = 0; i < randomposts_number; i++) {
        var entry = json.feed.entry[i];
        var randompoststitle = entry.title.$t;
        if ('content' in entry) {
            var randompostsnippet = entry.content.$t
        } else {
            if ('summary' in entry) {
                var randompostsnippet = entry.summary.$t
            } else {
                var randompostsnippet = "";
            }
        };
        randompostsnippet = randompostsnippet.replace(/<[^>]*>/g, "");
        if (randompostsnippet.length < randomposts_chars) {
            var randomposts_snippet = randompostsnippet
        } else {
            randompostsnippet = randompostsnippet.substring(0, randomposts_chars);
            var whitespace = randompostsnippet.lastIndexOf(" ");
            randomposts_snippet = randompostsnippet.substring(0, whitespace) + "&#133;";
        };
        for (var j = 0; j < entry.link.length; j++) {
            if ('thr$total' in entry) {
                var randomposts_commentsnum = entry.thr$total.$t + ' ' + randomposts_comments
            } else {
                randomposts_commentsnum = randomposts_commentsd
            }; if (entry.link[j].rel == 'alternate') {
                var randompostsurl = entry.link[j].href;
                var randomposts_date = entry.published.$t;
                if ('media$thumbnail' in entry) {
                    var randompoststhumb = entry.media$thumbnail.url
                } else {
                    randompoststhumb = "http://3.bp.blogspot.com/-5SoVe1K6JSk/Utl0OOmucAI/AAAAAAAAF6E/hQghgD_EJdQ/s1600/no_thumb.png"
                }
            }
        };
        document.write('<li>');
        document.write('<img alt="' + randompoststitle + '" src="' + randompoststhumb + '"/>');
        document.write('<div><a href="' + randompostsurl + '" rel="nofollow">' + randompoststitle + '</a></div>');
        if (randomposts_details == 'yes') {            document.write('<span>' + randomposts_date.substring(8, 10) + '.' + randomposts_date.substring(5, 7) + '.' + randomposts_date.substring(0, 4) + ' - ' + randomposts_commentsnum) + '</span>'
        }
        if (randomposts_details2 == 'yes') {            document.write('<span class="random-summary">' + randomposts_snippet) + '</span>'
        }
        document.write('<div style="clear:both"></div></li>')
    }
};getvalue();
for (var i = 0; i < randomposts_number; i++) {    document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index=' + randomposts_current[i] + '&max-results=1&callback=random_posts\"><\/script>')
};
</script>
</ul>
<div style="font-size: 10px; float: right;"><a href="http://www.spybaze.com/2017/01/how-to-add-random-posts-thumbnails.html" rel="nofollow">Random Posts Widget</a></div>

5. Click save

Go to your blog and refresh to see  Changes, This doesn't require any customarization as it works with your default post Feeds and automitcally change posts with every page loads.




Get Our Hottest Updates/Free Browsing Cheats via SMS. Kindly SMS FOLLOW Waxloaded to 40404. On Any Network. It Is Totally FREE.
Guest Post Or Sponsored Article, Click HERE For More Info

DOWNLOAD SPYBAZE ANDROID APP HERE
SHARE THIS

Author:

Spybaze.com.ng is a blog for all, we disseminate information about blogging tips, phones gadgets and review, data plans, latest working free browsing tweaks. Always visit spybaze.com.ng to enjoy our fantastic updates 24/7 just for you.


Follow us on our social platform below.
Welcome to your home of free browsing headquarter, Always & Keep Blazing 🔑🔑


Get latest Free Browsing Updates from spybaze
Follow us:
facebook twitter gplus pinterest rss

0 comments: