Cara Pasang Widget Ramdom Post di Blog - Find4Something

Cara Pasang Widget Ramdom Post di Blog

Cara Pasang Widget Ramdom Post | Find4something - Sobat Find4something kali Tentang Cara Pasang Widget Ramdom Post,, ok sesuai namanya sobat Find4something widget ini menampilkan artikel/postingan blog sobat secara acak mau coba widget ini ikuti langkah - langkah berikut.


Cara Pemasangan
  • Pergi ke Layout dan Klik Add Gadget.
  • Pilih HTML/Javascript widget.
  • Copy Code Html/Javascript di bawah lalu Pastekan di dalam box Content 
  • silahkan simpan dan lihat hasilnya

<!-- Random Post  -->

<!-- Style block for fancying-up the appearance -->
    .rp-post-link {
      font-weight: bold !important;
      font-size: 120% !important;
    .rp-summary {
      margin-top: 3px !important;
      font-size: 95% !important;
      line-height: 1.3em !important;
      word-wrap: break-word !important;
    .rp-thumbnail {
      margin: 5px 5px 2px 0px !important;
      float: left !important;
    .rp-pubdate {
      font-style: italic !important;
      margin-bottom: 3px !important;
<!-- end style block -->
<!-- Begin the script! -->
<script type="text/javascript">
    var randarray = new Array();
    var l=0;
    var flag;
    var lengthsummary = 155; //Number of characters to limit summary to
    var numofpost=5; //Number of random posts to display
    function randomposts(json){
        var total = parseInt(json.feed.openSearch$totalResults.$t,10);
      //fetch some random posts, making sure none are the same
        for(i=0; i < numofpost;){
                for(j in randarray){
     //Fetch the info from the posts and write them out
        for(n in randarray){
            var p=randarray[n];
            var entry=json.feed.entry[p-1]; //the object holding the feed data for a post
            var item =""; //holds the string to write out, containing all post info
          //----Post title link ----
            var posttitle = entry.title.$t || "[Untitled]"; //A post with no title is called "[Untitled]"
            //Looks like the 'alternate' link is *usually* last,
            //but we don't know if it's *always* last, so loop backwards
            //for efficiency and correctness!
            for( -1; k >= 0 ; k--){
                    item +="<a class='rp-post-link' href='" +[k].href + "'>" + posttitle + "</a>";
          //----end post title link ---
           item += "<br" //this weirdness is because the Blogger post editor is STUPID... sorry.
           item += "/>"
          //----publication date ----
           var pubdate = new Date(entry.published.$t).toDateString();
           item +="<span class='rp-pubdate'>Posted On " + pubdate +"</span>";
          //----end publication date ----
          //----Thumbnail images ----
            if('media$thumbnail' in entry)item += "<img class='rp-thumbnail' src='" +$thumbnail.url + "'>"
          //----end thumbnail images ----
          //---summary text ----
            var summary = "";
            //Feed will have EITHER "summary" or "content" variables, depending on feed settings
            if ("content" in entry) {
                summary = entry.content.$t;
            else if ("summary" in entry) {
                summary = entry.summary.$t;
            //Strip HTML tags out of post summary
            var re = /<\S[^>]*>/g;
            summary = summary.replace(re, "");
            item += "<p class='rp-summary'>" + summary.substring(0,lengthsummary) + " ...</p>";
          //----end summary text ---
           document.write(item); //write out the data from the post
        document.write('</div>'); //we've written out all the random post data! Done!
<!-- the following calls the randompost function and passes it, essentially, the blog's feed -->
<script src="/feeds/posts/default?alt=json-in-script&start-index=1&max-results=1000&callback=randomposts" type="text/javascript">
<!-- COPY HTML/JavaScript  END - -->


Oke Sobat Find4something Semoga Bermanfaat

Subscribe to receive free email updates:

2 Responses to "Cara Pasang Widget Ramdom Post di Blog"

  1. Saran gan, untuk memudahkan pengunjung membaca kode (bukan cuma copas doang) pke syntax highlighter dong :)