Membuat Recent Post dengan Thumbnail

Membuat Recent Post dengan Thumbnail - Kali ini saya akan berbagi tutorial Cara Membuat Recent Post dengan Thumbnail, selain dengan Thumbnail, Recent Post ini juga dilengkapi dengan Post Info seperti Tanggal Postingan, Komentar, dan Read More, dan sedikit efek pada Thumbnail yang pertama.

Membuat Recent Post dengan Thumbnail
Recent post ini muncul berdasarkan label tertentu yang sudah sobat setting lewat script nanti.

Pertama Buka Blogger > Template > Edit HTML > Lalu tambahkan kode CSS di bawah ini tepat di atas ]]></b:skin> atau </style>
/* Recent Post Widget */
ul.rp_thumbs{margin:0}ul.rp_thumbs li{font-size:12px;min-height:68px;margin:0 0 8px;padding:0 0 8px;border-bottom:1px dotted #f0f0f0}ul.rp_thumbs .rp_thumb{position:relative;background:#fbfbfb;margin:3px 0 10px;width:100%;height:0;padding-bottom:46%;overflow:hidden}ul.rp_thumbs .rp_thumb img{height:auto;width:100%;transition:transform 1.6s;transform:scale(1.0)}ul.rp_thumbs .rp_thumb:hover img{transform:scale(1.10)}ul.rp_thumbs2{font-size:13px}ul.rp_thumbs2 li{padding:0;min-height:66px;font-size:11px;margin:0 0 8px;padding:0 0 8px;border-bottom:1px dotted #f0f0f0}ul.rp_thumbs2 .rp_thumb2{background:#fbfbfb;float:left;margin:3px 8px 0 0;height:60px;width:60px}ul.rp_thumbs2 li:last-child{border-bottom:none;padding-bottom:0;margin-bottom:0}ul.rp_thumbs2 .rp_thumb2 img{height:60px;width:60px}.sidebar ul.rp_thumbs li:before,.sidebar ul.rp_thumbs2 li:before,#bottombar ul.rp_thumbs li:before,#bottombar ul.rp_thumbs2 li:before{display:none}span.rp_title{font:normal normal 18px Roboto Condensed,Helvetica,Arial,sans-serif;display:block;margin:0 0 5px;line-height:1.4em}span.rp_title2{font-size:14px}span.rp_summary{display:block;margin:6px 0 0}span.rp_meta{background:transparent;display:block;font-size:11px;font-weight:700;color:#8D8D8D;text-transform:uppercase}span.rp_meta a{color:#8D8D8D!important;display:inline-block}span.rp_meta_date,span.rp_meta_comment,span.rp_meta_more{display:inline-block;margin-right:8px}span.rp_meta_date:before{content:"\f073";font-family:FontAwesome;font-style:normal;font-weight:400;text-decoration:inherit;padding-right:4px}span.rp_meta_comment:before{content:"\f086";font-family:FontAwesome;font-style:normal;font-weight:400;text-decoration:inherit;padding-right:4px}span.rp_meta_more:before{content:"\f0a9";font-family:FontAwesome;font-style:normal;font-weight:400;text-decoration:inherit;padding-right:4px}ul.rp_thumbs2 li a:hover,ul.rp_thumbs li a:hover{color:#0072C6}
Langkah Selanjutnya tambahkan kode Javascript di bawah ini tepat di atas kode </head>
<script src='http://yourjavascript.com/34215101653/label-thumbnail.js' type='text/javascript'></script>
<script type='text/javascript'>
//<![CDATA[
function labelthumbs(t){for(var e=0;e<numposts;e++){var r,n=t.feed.entry[e],m=n.title.$t;if(e==t.feed.entry.length)break;for(var i=0;i<n.link.length;i++){if("replies"==n.link[i].rel&&"text/html"==n.link[i].type)var l=n.link[i].title,o=n.link[i].href;if("alternate"==n.link[i].rel){r=n.link[i].href;break}}var u;try{u=n.media$thumbnail.url,u=u.replace("/s72-c/","/w"+thumb_width+"-h"+thumb_height+"-c/")}catch(h){s=n.content.$t,a=s.indexOf("<img"),b=s.indexOf('src="',a),c=s.indexOf('"',b+5),d=s.substr(b+5,c-b-5),u=-1!=a&&-1!=b&&-1!=c&&""!=d?d:no_thumb}var p=n.published.$t,w=p.substring(0,4),_=p.substring(5,7),f=p.substring(8,10);document.write('<ul class="rp_thumbs">'),document.write("<li>"),1==showpostthumbnails&&document.write('<a href="'+r+'"><div class="rp_thumb"><span class="rollover"></span><img width="'+thumb_width+'" height="'+thumb_height+'" alt="'+m+'" src="'+u+'"/></div></a>'),document.write('<span class="rp_title"><a href="'+r+'" target ="_top">'+m+"</a></span>");var g="";if(document.write('<span class="rp_meta">'),1==showpostdate&&(g=g+'<span class="rp_meta_date">'+f+"/"+_+"/"+w+"</span>"),1==showcommentnum&&("1 Comments"==l&&(l="1 Comment"),"0 Comments"==l&&(l="No Comments"),showcomment='<span class="rp_meta_comment"><a href="'+o+'">'+l+"</a></span>",g+=showcomment),1==displaymore&&(g=g+'<span class="rp_meta_more"><a href="'+r+'" class="url" target ="_top">Read More...</a></span>'),document.write(g),document.write("</span>"),document.write('<span class="rp_summary">'),"content"in n)var v=n.content.$t;else if("summary"in n)var v=n.summary.$t;else var v="";var k=/<\S[^>]*>/g;if(v=v.replace(k,""),1==showpostsummary)if(v.length<numchars)document.write(""),document.write(v),document.write("");else{document.write(""),v=v.substring(0,numchars);var y=v.lastIndexOf(" ");v=v.substring(0,y),document.write(v+"..."),document.write("")}document.write("</span>"),document.write("</li>"),document.write("</ul>")}document.write('<ul class="rp_thumbs2">');for(var e=1;e<numposts2;e++){var r,n=t.feed.entry[e],m=n.title.$t;if(e==t.feed.entry.length)break;for(var i=1;i<n.link.length;i++){if("replies"==n.link[i].rel&&"text/html"==n.link[i].type)var l=n.link[i].title,o=n.link[i].href;if("alternate"==n.link[i].rel){r=n.link[i].href;break}}var $;try{$=n.media$thumbnail.url.replace("/s72-c/","/w"+thumb_width2+"-h"+thumb_height2+"-c/")}catch(h){s=n.content.$t,a=s.indexOf("<img"),b=s.indexOf('src="',a),c=s.indexOf('"',b+5),d=s.substr(b+5,c-b-5),$=-1!=a&&-1!=b&&-1!=c&&""!=d?d:no_thumb2}var p=n.published.$t,w=p.substring(0,4),_=p.substring(5,7),f=p.substring(8,10);1==showpostthumbnails2&&document.write('<a href="'+r+'"><div class="rp_thumb2"><img width="'+thumb_width2+'" height="'+thumb_height2+'" alt="'+m+'" src="'+$+'"/></div></a>'),document.write("<li>"),document.write('<span class="rp_title rp_title2"><a href="'+r+'" target ="_top">'+m+"</a></span>");var g="";document.write('<span class="rp_meta rp_meta2">'),1==showpostdate2&&(g=g+'<span class="rp_meta_date rp_meta_date2">'+f+"/"+_+"/"+w+"</span>"),1==showcommentnum2&&("1 Comments"==l&&(l="1 Comment"),"0 Comments"==l&&(l="No Comments"),showcomment='<span class="rp_meta_comment rp_meta_comment2"><a href="'+o+'">'+l+"</a></span>",g+=showcomment),1==displaymore2&&(g=g+'<span class="rp_meta_more rp_meta_more2"><a href="'+r+'" class="url" target ="_top">Read More...</a></span>'),document.write(g),document.write("</span>"),document.write("</li>")}document.write("</ul>")}
//Recent Comments
var numComments=numComments||5,characters=characters||40;function recent_comments(tb){var commentsHtml;commentsHtml='<ul id="recent_comments">';for(var i=0;i<numComments;i++){var commentlink,authorName;if(i==tb.feed.entry.length)break;commentsHtml+="<li>";var entry=tb.feed.entry[i];for(var l=0;l<entry.link.length;l++){if(entry.link[l].rel=='alternate'){commentlink=entry.link[l].href}}for(var a=0;a<entry.author.length;a++){authorName=entry.author[a].name.$t}commentsHtml+="<strong><a href=\""+commentlink+"\" title=\""+authorName+"\">"+authorName+"</a></strong>";var commHTML=entry.content.$t;var commBody=commHTML.replace(/(<([^>]+)>)/ig,"");if(commBody!=""&&commBody.length>characters){commBody=commBody.substring(0,characters);commBody+=" &hellip;"}else{commBody=commBody}commentsHtml+=" - ";commentsHtml+="<span>"+commBody+"</span>";commentsHtml+="</li>"}commentsHtml+='</ul>';document.write(commentsHtml)}
//]]>
//Recent Comments Settings
var numComments  = 5;
var characters  = 60;
</script>
<script type='text/javascript'>
var numposts = 1;
var numposts2 = 4;
var showpostthumbnails = true;
var showpostthumbnails2 = true;
var displaymore = true;
var displaymore2 = false;
var showcommentnum = true;
var showcommentnum2 = true;
var showpostdate = true;
var showpostdate2 = true;
var showpostsummary = true;
var numchars = 100;
var thumb_width = 300;
var thumb_height = 140;
var thumb_width2 = 60;
var thumb_height2 = 60;
var no_thumb = 'http://1.bp.blogspot.com/-7vDs5hMaDho/U268E2ecF4I/AAAAAAAADY8/RBHVTTuJrxc/w300-h140-c/no-image.png'
var no_thumb2 = 'http://3.bp.blogspot.com/-ltyYh4ysBHI/U04MKlHc6pI/AAAAAAAADQo/PFxXaGZu9PQ/s60-c/no-image.png'
</script>
Simpan Template.

Nah untuk memunculkan Widget, Pilih Tata Letak > Tambahkan Widget > Pilih HTML/Javascript lalu masukan kode di bawah ini.
<script>
   document.write('<div class="recent-post-title"><h2><a href="/search/label/Kisah?max-results=10">Label 1</a></h2></div>');
   document.write("<script src=\"/feeds/posts/default/-/Kisah?orderby=updated&alt=json-in-script&callback=labelthumbs\"><\/script>");
   </script>
Ganti Kisah dengan label sobat yang di pilih.

Setelah itu Simpan.

Demikianlah tutorial saya kali ini tentang cara membuat recent poct dengan thumbnail. Happy Blogging!

Berlangganan update artikel terbaru via email:

0 Response to "Membuat Recent Post dengan Thumbnail"

Post a Comment

Jika ada yang kurang jelas silahkan tambahkan ke kolom komentar dibawah ini.
- Dilarang SPAM
- Dilarang Menghina
- Dilarang PROMOSI

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel