Cara membuat, memunculkan, atau menampilkan widget Random Posts di blog
RANDOM Posts adalah daftar posting yang ditampilkan otomatis "secara acak" atau muncul secara bergantian.
Kata para pakar SEO, Random Post itu bagus buat SEO Blog dan disukasi user.
Lihat DEMO. Klik salah satu posting di sana dan lihat di sidebar bagian bawah.Cara membuat Random Post seperti demo tersebut ada di Tips Nomor #4 di bawah.
FUNGSI RANDOM POSTSRandom post berfungsi sebagai navigasi dan internal links. Dengan adanya Widget Random Posts --selain Related Posts dan Recent Posts, user atau pengunjung blog akan lebih mudah menjelajahi konten blog kita.
Mereka pun bisa berlama-lama tuh buka dan baca blog kita, bagus buat
Page Rank!
Random Posts is a widget allow your visitors discover your old posts easily each time they refresh your blog on Blogger. Random Post adalah widget yang memudahkan pengunjung Anda membuka posting lama tiap kali mereka refresh blog Anda di blogger. Gitu katanya....
Cara Membuat Widget Random Posts #1 Fast Loading!
Dibandingkan kode random posts lainnya, kode dari
DTE ini paling cepat, tidak lelet atau "relatif" tidak memperlambat loading blog.
1. "Layout" > "Add Gadget" > pilih "JavaScript/HTML"
2. Isi judul widget dengan "Random Posts" (bisa pula nama lain)
3. Copy & Paste kode berikut ini di kolom "Content"
<div id='random-post-container'>Memuat...</div>
<script>
//<![CDATA[
// Feed configuration
var homePage = 'http://contohblognih.blogspot.com',
maxResults = 5,
containerId = 'random-post-container';
// Function to generate random number limited from `min` to `max`
// Used to create a valid and safe random feed `start-index`
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Function to shuffle arrays
// Used to randomize order of the generated JSON feed
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] = temp;
}
return arr;
}
// Get a random start index
function createRandomPostsStartIndex(json) {
var startIndex = getRandomInt(1, (json.feed.openSearch$totalResults.$t - maxResults));
// console.log('Get the post feed start from ' + startIndex + ' until ' + (startIndex + maxResults));
document.write('<scr' + 'ipt src="' + homePage + '/feeds/posts/summary?alt=json-in-script&orderby=updated&start-index=' + startIndex + '&max-results=' + maxResults + '&callback=randomPosts"></scr' + 'ipt>');
}
// Widget's main function
function randomPosts(json) {
var link, ct = document.getElementById(containerId),
entry = shuffleArray(json.feed.entry),
skeleton = "<ul>";
for (var i = 0, len = entry.length; i < len; i++) {
for (var j = 0, jen = entry[i].link.length; j < jen; j++) {
link = (entry[i].link[j].rel == "alternate") ? entry[i].link[j].href : '#';
}
skeleton += '<li><a href="' + link + '">' + entry[i].title.$t + '</a></li>';
}
ct.innerHTML = skeleton + '</ul>';
}
document.write('<scr' + 'ipt src="' + homePage + '/feeds/posts/summary?alt=json-in-script&max-results=0&callback=createRandomPostsStartIndex"></scr' + 'ipt>');
//]]>
</script>
4. Ubah alamat nama blog
warna merah dengan "kepunyaan" Anda!
5. Save!
Jadi deh tuh... widget
random post Anda sudah muncul di sidebar atau di footer widget blog Anda!
Kode HMTL Random Posts Daftar Judul #2
Untuk membuat random posts serupa, daftar judul saja, kita bisa gunakan kode HTML berikut ini. Caranya:
1. Layout > Add Gagdget > pilih "HTML/Javascript"
2 Copas kode berikut ini di kolom Content.
3. Jangan lupa ubah
contohblognih dengan nama blog Anda.
4. Save!
<script type="text/javascript">
var randarray = new Array();var l=0;var flag;var numofpost=10;function randomposts(json){var total =parseInt(json.feed.openSearch$totalResults.$t,10);for(i=0;i < numofpost;){flag=0;randarray.length=numofpost;l=Math.floor(Math.random()*total);for(j in randarray){if(l==randarray[j]){ flag=1;}}if(flag==0&&l!=0){randarray[i++]=l;}}document.write('<ul>'); for(n in randarray){ var p=randarray[n];var entry=json.feed.entry[p-1];for(k=0; k < entry.link.length;k++){if(entry.link[k].rel=='alternate'){var item = "<li>" + "<a href=" + entry.link[k].href + ">" + entry.title.$t + "</a> </li>";document.write(item);}}}document.write('</ul>');}</script> <script src="http://www.contohblognih.blogspot.com/feeds/posts/default?alt=json-in-script&start-index=1&max-results=1000&callback=randomposts" type="text/javascript"></script>
Cara Membuat Widget Random Posts #3
Alternatif lain membuat random pots (lihat
Demo) adalah sebagai berikut:
1. Tambahkan kode berikut sebelum kode
]]></b:skin> random-posts img {
float:left;
margin-right:10px;
border:1px solid #999;
background:#FFF;
width:36px;
height:36px;
padding:3px
}
2. Save Template!Kembali ke Dashboard...!3. Klik "Layout" > "Add Gadget" > Pilih "HTML/Javascript"
4. Copy & Paste kode berikut ini:
<ul id='random-posts'>
<script type='text/javaScript'>
var rdp_numposts=5;
var rdp_snippet_length=150;
var rdp_info='yes';
var rdp_comment='komentar';
var rdp_disable='Comments Off';
var rdp_current=[];var rdp_total_posts=0;var rdp_current=new Array(rdp_numposts);function totalposts(json){rdp_total_posts=json.feed.openSearch$totalResults.$t}document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=totalposts\"><\/script>');function getvalue(){for(var i=0;i<rdp_numposts;i++){var found=false;var rndValue=get_random();for(var j=0;j<rdp_current.length;j++){if(rdp_current[j]==rndValue){found=true;break}};if(found){i--}else{rdp_current[i]=rndValue}}};function get_random(){var ranNum=1+Math.round(Math.random()*(rdp_total_posts-1));return ranNum};
</script>
<script type='text/javaScript'>
function random_posts(json){a=location.href;y=a.indexOf('?m=0');for(var i=0;i<rdp_numposts;i++){var entry=json.feed.entry[i];var rdp_posttitle=entry.title.$t;if('content'in entry){var rdp_get_snippet=entry.content.$t}else{if('summary'in entry){var rdp_get_snippet=entry.summary.$t}else{var rdp_get_snippet="";}};rdp_get_snippet=rdp_get_snippet.replace(/<[^>]*>/g,"");if(rdp_get_snippet.length<rdp_snippet_length){var rdp_snippet=rdp_get_snippet}else{rdp_get_snippet=rdp_get_snippet.substring(0,rdp_snippet_length);var space=rdp_get_snippet.lastIndexOf(" ");rdp_snippet=rdp_get_snippet.substring(0,space)+"…";};for(var j=0;j<entry.link.length;j++){if('thr$total'in entry){var rdp_commentsNum=entry.thr$total.$t+' '+rdp_comment}else{rdp_commentsNum=rdp_disable};if(entry.link[j].rel=='alternate'){var rdp_posturl=entry.link[j].href;if(y!=-1){rdp_posturl=rdp_posturl+'?m=0'}var rdp_postdate=entry.published.$t;if('media$thumbnail'in entry){var rdp_thumb=entry.media$thumbnail.url}else{rdp_thumb="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWU42VZLcoEkTLYDzW8jZeI4Yri5kcFkj4JRyGWWNf0L95kyCuFYH1N9FGfFBUP72pXJcFg1OHEghy7X-8CL7TZNWhXlue1Gw2uogEOltX8W6iEkzDVnQDsGWnvKFpBKAIh8NMU33Lo9xg/"}}};document.write('<li>');document.write('<img alt="'+rdp_posttitle+'" src="'+rdp_thumb+'"/>');document.write('<div><a href="'+rdp_posturl+'" rel="nofollow" title="'+rdp_snippet+'">'+rdp_posttitle+'</a></div>');if(rdp_info=='yes'){document.write('<span>'+rdp_postdate.substring(8,10)+'/'+rdp_postdate.substring(5,7)+'/'+rdp_postdate.substring(0,4)+' - '+rdp_commentsNum)+'</span>'}document.write('<div style="clear:both"></div></li>')}};getvalue();for(var i=0;i<rdp_numposts;i++){document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index='+rdp_current[i]+'&max-results=1&callback=random_posts\"><\/script>')};
</script>
</ul>
5. Save!Cara Membuat Widget Random Posts #4
Ini cara termudah, gak pake ribet. DEMO-nya di halaman dalam
CB Blogger Lab, di sidebar paling bawah. Indah pula!
1. Layout > Add a Gadget > pilih HTML/Javascript
2. Copy + Paste kode berikut ini di dalam "Content".
Judulnya widget bisa diisi "Random Posts", bisa juga yang lain, misalnya "Posting Menarik Lainnya".
<style>
#random-posts img{float:left;margin-right:10px;
width:65px;height:50px;background-color: #F5F5F5;padding: 3px;}
ul#random-posts {list-style-type: none;}
</style>
<ul id='random-posts'>
<script type='text/javaScript'>
var rdp_numposts=5;
var rdp_snippet_length=150;
var rdp_info='yes';
var rdp_comment='Comments';
var rdp_disable='Comments Disabled';
var rdp_current=[];var rdp_total_posts=0;var rdp_current=new Array(rdp_numposts);function totalposts(json){rdp_total_posts=json.feed.openSearch$totalResults.$t}document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=totalposts\"><\/script>');function getvalue(){for(var i=0;i<rdp_numposts;i++){var found=false;var rndValue=get_random();for(var j=0;j<rdp_current.length;j++){if(rdp_current[j]==rndValue){found=true;break}};if(found){i--}else{rdp_current[i]=rndValue}}};function get_random(){var ranNum=1+Math.round(Math.random()*(rdp_total_posts-1));return ranNum};
</script>
<script type='text/javaScript'>
function random_posts(json){for(var i=0;i<rdp_numposts;i++){var entry=json.feed.entry[i];var rdp_posttitle=entry.title.$t;if('content'in entry){var rdp_get_snippet=entry.content.$t}else{if('summary'in entry){var rdp_get_snippet=entry.summary.$t}else{var rdp_get_snippet="";}};rdp_get_snippet=rdp_get_snippet.replace(/<[^>]*>/g,"");if(rdp_get_snippet.length<rdp_snippet_length){var rdp_snippet=rdp_get_snippet}else{rdp_get_snippet=rdp_get_snippet.substring(0,rdp_snippet_length);var space=rdp_get_snippet.lastIndexOf(" ");rdp_snippet=rdp_get_snippet.substring(0,space)+"…";};for(var j=0;j<entry.link.length;j++){if('thr$total'in entry){var rdp_commentsNum=entry.thr$total.$t+' '+rdp_comment}else{rdp_commentsNum=rdp_disable};if(entry.link[j].rel=='alternate'){var rdp_posturl=entry.link[j].href;var rdp_postdate=entry.published.$t;if('media$thumbnail'in entry){var rdp_thumb=entry.media$thumbnail.url}else{rdp_thumb="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0AlNKhm0bbDQxMcAvSx_tkHielWD1vKYd6Ev8kLqYezmH1kns5sbc6CyL4hBmTlt1ZWPUibk_lPwnh_pjnINnFUwrxu9ptExhRBiw4awiF2TkQ_cigZF30RpM4-O8fAgrxmG-8DtiJ5o/s1600/no_thumb.png"}}};document.write('<li>');document.write('<img alt="'+rdp_posttitle+'" src="'+rdp_thumb+'"/>');document.write('<div><a href="'+rdp_posturl+'" rel="nofollow" title="'+rdp_snippet+'">'+rdp_posttitle+'</a></div>');if(rdp_info=='yes'){document.write('<span>'+rdp_postdate.substring(8,10)+'/'+rdp_postdate.substring(5,7)+'/'+rdp_postdate.substring(0,4)+' - '+rdp_commentsNum)+'</span>'}document.write('<div style="clear:both"></div></li>')}};getvalue();for(var i=0;i<rdp_numposts;i++){document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index='+rdp_current[i]+'&max-results=1&callback=random_posts\"><\/script>')};
</script>
</ul>
Kalau mau JUDUL doang tanpa Gambar dan tanggal, gunakan kode ini:
<style>
#random-posts{border:1px solid #aaa;font-size:10pt;margin:auto;padding:0}
#random-posts li{background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO5Jac-h4IKnO6EmQY6CzgScIqw1Pm5Xpy2IeUI3kwLJfyvB4NgWSO-chdu8VUO_nOPi_qm6EQlMT4nPtcFpO17UnkPelHdghsepYcg_Zo84oXOrCuWLAY7BBlqVbUPTBDAY2tnJktk_6k/s1600/sprites.png) no-repeat 0 -67px;border-bottom:1px solid #ccc;height:36px;line-height:1.5em;list-style-type:none;margin:0;overflow:hidden;padding:6px 10px 10px 3.5em !important}
#random-posts img{display:none}
#random-posts{background:#f6f6f6;background: -webkit-gradient(linear, 0% 40%, 0% 70%, from(#f9f9f9), to(#f1f1f1));background: -moz-linear-gradient(linear, 0% 40%, 0% 70%, from(#f9f9f9), to(#f1f1f1))},#random-posts
</style>
<div id='random-posts'>
<script type='text/javaScript'>
var rdp_numposts=7;var rdp_snippet_length=0;var rdp_info='no';var rdp_current=[];var rdp_total_posts=0;var rdp_current=new Array(rdp_numposts);function totalposts(json){rdp_total_posts=json.feed.openSearch$totalResults.$t}document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=totalposts\"><\/script>');function getvalue(){for(var i=0;i<rdp_numposts;i++){var found=false;var rndValue=get_random();for(var j=0;j<rdp_current.length;j++){if(rdp_current[j]==rndValue){found=true;break}};if(found){i--}else{rdp_current[i]=rndValue}}};function get_random(){var ranNum=1+Math.round(Math.random()*(rdp_total_posts-1));return ranNum};
</script><script type='text/javaScript'>
function random_posts(json){for(var i=0;i<rdp_numposts;i++){var entry=json.feed.entry[i];var rdp_posttitle=entry.title.$t;if('content'in entry){var rdp_get_snippet=entry.content.$t}else{if('summary'in entry){var rdp_get_snippet=entry.summary.$t}else{var rdp_get_snippet="";}};rdp_get_snippet=rdp_get_snippet.replace(/<[^>]*>/g,"");if(rdp_get_snippet.length<rdp_snippet_length){var rdp_snippet=rdp_get_snippet}else{rdp_get_snippet=rdp_get_snippet.substring(0,rdp_snippet_length);var space=rdp_get_snippet.lastIndexOf(" ");rdp_snippet=rdp_get_snippet.substring(0,space)+"…";};for(var j=0;j<entry.link.length;j++){if('thr$total'in entry);if(entry.link[j].rel=='alternate'){var rdp_posturl=entry.link[j].href;var rdp_postdate=entry.published.$t;if('media$thumbnail'in entry){var rdp_thumb=entry.media$thumbnail.url}else{rdp_thumb="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEik_WCCrHuxINbsNKoZBCPgzTJLX3PfLdFSbOitDB5n1B-9UAUHAz8ZQR7kg_QKZABL8_IK3fUgq74Kz_LK5FN9E8SfUP7YNm3bMcpHgiztPeVw_RlrvZZtARmCfQaxkMKrNtMff_47i7Y/s1600/default.jpg"}}};document.write('<li>');document.write('<img alt="'+rdp_posttitle+'" src="'+rdp_thumb+'"/>');document.write('<div><a href="'+rdp_posturl+'" title="'+rdp_posttitle+'">'+rdp_posttitle+'</a></div>');if(rdp_info=='yes'){document.write('<span>'+rdp_postdate.substring(8,10)+'/'+rdp_postdate.substring(5,7)+'/'+rdp_postdate.substring(0,4)+' - '+rdp_commentsNum)+'</span>'}document.write('<div style="clear:both"></div></li>')}};getvalue();for(var i=0;i<rdp_numposts;i++){document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index='+rdp_current[i]+'&max-results=1&callback=random_posts\"><\/script>')}
</script></div>
4. Save!
CARA LAIN
Cara lainnya? Banyak banget ya....! Memang cukup banyak blogger yang berbagi tips sekaligus menyediakan kode Random Posts untuk blog Anda.
Selain yang di atas, ini dia yang lainnya:
- Help Blogger
- Masih Help Blogger
- Blogspot Tutorial
- Yang horisontal ada di Bloggerneur
- NetOops Blog
Nah itu dia 8 macam cara Cara Membuat Widget Random Posts di Blogspot ... Silakan dipilih dipilihhhh......! Good Luck!