Tampilkan postingan dengan label related posts. Tampilkan semua postingan
Tampilkan postingan dengan label related posts. Tampilkan semua postingan

How to customize or edit the linkwithin related post widget

LinkWithin is a very popular widget that shows the related posts with a thumbnail and although it is not a new gadget among bloggers, many avoid using it for its lack of customization. So, in this post we will see how to add LinkWithin on a Blogger blog and how to customize it.

This is what we will do with this gadget:

- Change the location of the gadget;
- Remove the LinkWithin link;
- Change the "You might also like" title with any other text;
- Add rounded borders to images;
- Remove the border that separates posts;
- Add a background color;
- Change the background color on mouse over;
- Change the post titles color and font

Adding the LinkWithin gadget to Blogger

First of all we need to install the LinkWithin gadget - for this, we have to go to the LinkWithin homepage and type in the required information:

linkwithin gadget, related posts widget, blogger widgets
Although it gives the option to choose Blogger as a platform, we will select Other so that we'll be able to put the code directly into our template and then modify it. Select the number of posts (stories) according to the width of posts - if the width of the posts container is small, then it is recommended to display fewer related posts.

By clicking on the "Get widget!" button, we'll be given the code that we need use it. It should look something like this:
<script>
var linkwithin_site_id = XXXXXXX;
</script>
<script src="http://www.linkwithin.com/widget.js"></script>
<a href="http://www.linkwithin.com/"><img src="http://www.linkwithin.com/pixel.png" alt="Related Posts Plugin for WordPress, Blogger..." style="border: 0" /></a>
That's the basic code we need to copy. Now login into your Blogger account > select your blog to where you want to add the LinkWithin gadget and go to Template > click on the Edit HTML button:


Cick anywhere inside the code area and press the CTRL + F keys to search for the following line:
<div class='post-footer'>
Just above this line, paste the LinkWithin code.

By doing so you already have the LinkWithin gadget on your blog and the result will be like this:

linkwithin gadget, related posts widget, blogger widgets
Note: If you would like to show only in the individual post, you can enclose the code using a conditional.

Change the LinkWithin gadget location

You will notice that this widget will always appear right at the end of your posts. In the LinkWithin FAQ page we are explained how to fix this - simply add the code below where we want the widget to appear:
<div class='linkwithin_div'/>
This will make the gadget to display right where we added the code. Even if we don't want to change the gadget location, this line is required so that we can customize it later.

Replacing the "You might also like" text

By default, the LinkWithin gadget will have the title "You might also like" and we can change that text to anything we want. Just add the line below in blue within the LinkWithin code:
<div class='linkwithin_div'/>
<script>
var linkwithin_site_id = XXXXXXX;
</script>
<script>linkwithin_text='Related Posts:'</script>
<script src="http://www.linkwithin.com/widget.js"></script>
<a href="http://www.linkwithin.com/"><img src="http://www.linkwithin.com/pixel.png" alt="Related Posts Plugin for WordPress, Blogger..." style="border: 0" /></a>
Here you can change the text - in this case, it will say "Related posts" instead of "You may also like these stories".

Changing the LinkWithin background color and thumbnails style

Within the template's code, search for the ]]></b:skin> tag and just above it, add the following CSS styling:
.linkwithin_div {
background: #EEEEEE; /* Background color for the related posts container */
padding: 0 10px;
border-top: 1px solid #DBDBDB;  /* Top border for the related posts container */
border-bottom: 1px solid #DBDBDB;  /* Bottom border for the related posts container */
}
.linkwithin_text {
font-family: Cambria,Georgia,sans-serif;
font-size:18px; /* Size for the related posts title */
color:#898989; /* Color for the related posts title */
}
a#linkwithin_logolink_0, a#linkwithin_logolink_1, a#linkwithin_logolink_2, a#linkwithin_logolink_3, a#linkwithin_logolink_4, a#linkwithin_logolink_5, a#linkwithin_logolink_6, a#linkwithin_logolink_7, a#linkwithin_logolink_8, a#linkwithin_logolink_9, a#linkwithin_logolink_10, a#linkwithin_logolink_11, a#linkwithin_logolink_12, a#linkwithin_logolink_13, a#linkwithin_logolink_14, a#linkwithin_logolink_15, a#linkwithin_logolink_16, a#linkwithin_logolink_17, a#linkwithin_logolink_18, a#linkwithin_logolink_19, a#linkwithin_logolink_20 {
display:none;
}
.linkwithin_posts {
width: 500px !important; /* Width for the related posts container */
}
.linkwithin_posts a {
border: 0 !important;
padding-right: 10px !important;
}
.linkwithin_posts a:hover {
background: #F5F5F5 !important; /* Background color on mouseover */
}
.linkwithin_img_0 {
background: #F5F5F5;
border: 1px solid #C1C1C1;
padding: 2px !important;
transition:all .2s linear;
 -o-transition:all .5s linear;
-moz-transition:all .2s linear;
-webkit-transition:all .2s linear;
}
.linkwithin_img_0:hover {
background: #ffffff;
padding: 2px !important;
opacity:.6;
filter:alpha(opacity=60)

.linkwithin_img_0 div, div.linkwithin_img_0,
.linkwithin_img_1 div, div.linkwithin_img_1,
.linkwithin_img_2 div, div.linkwithin_img_2,
.linkwithin_img_3 div, div.linkwithin_img_3,
.linkwithin_img_4 div, div.linkwithin_img_4,
.linkwithin_img_5 div, div.linkwithin_img_5,
.linkwithin_img_6 div, div.linkwithin_img_6,
.linkwithin_img_7 div, div.linkwithin_img_7,
.linkwithin_img_8 div, div.linkwithin_img_8,
.linkwithin_img_9 div, div.linkwithin_img_9,
.linkwithin_img_10 div, div.linkwithin_img_10,
.linkwithin_img_11 div, div.linkwithin_img_11,
.linkwithin_img_12 div, div.linkwithin_img_12,
.linkwithin_img_13 div, div.linkwithin_img_13,
.linkwithin_img_14 div, div.linkwithin_img_14,
.linkwithin_img_15 div, div.linkwithin_img_15,
.linkwithin_img_16 div, div.linkwithin_img_16,
.linkwithin_img_17 div, div.linkwithin_img_17,
.linkwithin_img_18 div, div.linkwithin_img_18,
.linkwithin_img_19 div, div.linkwithin_img_19,
.linkwithin_img_20 div, div.linkwithin_img_20 {
-webkit-border-radius: 100px;
-moz-border-radius: 100px;
border-radius: 100px;

}
.linkwithin_title {
color: #242424 !important; /* Color for titles */
font-family: Cambria,Georgia,sans-serif;
font-size: 12px !important; /* Font size of posts titles */
line-height: 24px !important;
text-align:center;
text-decoration: none;
}
.linkwithin_title:hover {
color: #000 !important; /* Color of posts titles on mouseover */
}
After adding this CSS, the LinkWithin gadget will look like this:

linkwithin gadget, related posts widget, blogger widgets

If you don't want rounded thumbnails, remove the code in red. In green you can see the parts which can be customized - there you can add more styles or change the background color, text size, etc.

After you've made the changes, click on the Save Template button and you're done. Enjoy!

Related Posts Widget with Thumbnails and Summary for Blogger

There are several tutorials quite old in which I have shown different methods for displaying related posts in Blogger [1] [2] but in this tutorial, you will learn how to implement a really awesome Related Posts widget with Thumbnails and Posts Snippets that will appear in the footer of all your blog posts. If you want to get an idea of how it looks like, please visit this demo blog.

Now let's see how to add the related posts widget with thumbnails and summaries in a Blogger template:

Adding Related Posts Widget with Summaries to Blogger
related posts widget with thumbnails and summaries

Step 1. From your Blogger Dashboard, go to Template and click on Edit HTML


Step 2. Click anywhere inside the code area and then press CTRL + F to open the Blogger search box


Step 3. Type or paste this tag inside the search box and hit enter to find it:
</head>
After you found it, paste this script just above it:
<script type='text/javascript'>
//<![CDATA[
var relatedTitles = new Array();
var relatedUrls = new Array();
var relatedpSummary = new Array();
var relatedThumb = new Array();
var relatedTitlesNum = 0;
var relatedPostsNum = 4; // number of entries to be shown
var relatedmaxnum = 75; // the number of characters of summary
var relatednoimage = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsw5J4WjW9rZPDOgdnwZQJC0ByEzlSLmxls0qDP3PwdfZrGZtGojOxaNMXZuwhj9aistRWWESZLOl6o1oEmK2mBL7RirV0n1uFnJxzc0RDhbwQ1z5AVgfMQjzoTybKzAqzws0ZGcy-nqdz/s1600/no_image.jpg"; // default picture for entries with no image
//]]>
</script>
<script src="http://helplogger.googlecode.com/svn/trunk/related-posts-with-thumbs-and-summaries.js" />
Note:  
    - To change the number of posts that are being displayed, modify the value in red (4)
    - To change the number of characters to be shown in posts summary, modify the value in green (75)
    - To change the default pic for posts with no images, add your URL instead of the one marked in blue

      Now that we added the script, we will need to add the style. Paste the following code above the same </head> tag:
      <style>
      .relatedsumposts {
          float: left;
          padding: 0px 10px;
          overflow: hidden;
          text-align: center;
        /* width and height of the related posts area */
          width: 120px;
          height: 200px;
          border-right: 1px solid #E5E5E5;
          display: inline-block;
      }

      .relatedsumposts:hover {
          background-color: #F7F7F7;
      }

      .relatedsumposts img:hover {
          -webkit-transform: rotate(360deg);
          -moz-transform: rotate(360deg);
          -o-transform: rotate(360deg);
      }

      .relatedsumposts a {
        /* link properties */
          color: #linkcolor;
          display: inline;
          font-size: 10px;
          line-height: 1;
      }

      .relatedsumposts img {
        /* thumbnail properties */
          margin-top: 2px;
          height: 82px;
          padding: 5px;
          width: 82px;
          border: 1px solid #fff;
          -webkit-border-radius: 100px;
          -moz-border-radius: 100px;
          border-radius: 100px;

          -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
          -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
          box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
          -webkit-transition-duration: 0.8s;
          -moz-transition-duration: 0.8s;
          -o-transition-duration: 0.8s;
          transition-duration: 0.8s;
          -webkit-transition-property: -webkit-transform;
          -moz-transition-property: -moz-transform;
          -o-transition-property: -o-transform;
          transition-property: transform;
          overflow: hidden;
      }

      .relatedsumposts h6 {
        /* title properties */
          display: table-cell;
          height: 3em;
          margin: 5px 0 0;
          overflow: hidden;
          padding-bottom: 2px;
          vertical-align: middle;
          width: 130px;
      }

      .relatedsumposts p {
        /* summary properties */
          border-top: 1px solid #E5E5E5;
          border-bottom: 1px solid #E5E5E5;
          color: #summarycolor;
          font-size: 10px;
          height: 4em;
          line-height: 1;
          margin: 5px 0 0;
          overflow: hidden;
          padding: 5px 0 15px 0;
          text-align: left;
      }

      #relatedpostssum {
          background: #F3F3F3;
          height: 200px; /* related posts container */
          padding: 5px;
          width: 100%;
      }

      .relatedpoststitle {
          font-size: 19px;
          font-weight: bold;
          border-top: 3px solid #FB8227;
          color: #777;
          display: inline-block;
          padding: 5px 10px;
          width: 190px;
          float: left;
          margin: 0px -200px 0px 20px;
          transform: rotate(90deg);
          transform-origin: left top 0;
          -ms-transform: rotate(90deg);
          -ms-transform-origin:left top 0;
          -webkit-transform: rotate(90deg);
          -webkit-transform-origin:left top 0; 
         font-family: Gill Sans / Gill Sans MT, sans-serif;
      }
      </style>
      Note:  
        - Modify the values in red to adjust the width (120) and height (210) of the widget area
        - Replace #linkcolor with the hex value of your color to change the color of post titles
        - If you want to change the size of thumbnails, modify the values marked in violet (82)
        - To determine the border roundness, modify the values in orange (100)
        - To change the color of the post snippet, change #summarycolor with color hex value
        - In case you add more that 5 related posts, change the container height 200px to 400px

        2nd Note: If you have a dark background, you may want to add this style instead (see the screenshot):

        related posts widget with thumbnails and summaries
         <style>
        .relatedsumposts {
            float: left;
            padding: 0px 10px;
            overflow: hidden;
            text-align: center;
          /* width and height of the related posts area */
            width: 120px;
            height: 200px;
            border-right: 1px solid #0A0A0A;
            display: inline-block;
        }

        .relatedsumposts:hover {
            background-color: #0A0A0A;
        }

        .relatedsumposts img:hover {
            -webkit-transform: rotate(360deg);
            -moz-transform: rotate(360deg);
            -o-transform: rotate(360deg);
        }

        .relatedsumposts a {
          /* link properties */
            color: #linkcolor;
            display: inline;
            font-size: 10px;
            line-height: 1;
        }

        .relatedsumposts img {
          /* thumbnail properties */
            margin-top: 2px;
            height: 82px;
            padding: 5px;
            width: 82px;
            border: 1px solid #000;
        background:#282828;
            -webkit-border-radius: 100px;
            -moz-border-radius: 100px;
            border-radius: 100px;

            -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
            -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
            box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
            -webkit-transition-duration: 0.8s;
            -moz-transition-duration: 0.8s;
            -o-transition-duration: 0.8s;
            transition-duration: 0.8s;
            -webkit-transition-property: -webkit-transform;
            -moz-transition-property: -moz-transform;
            -o-transition-property: -o-transform;
            transition-property: transform;
            overflow: hidden;
        }

        .relatedsumposts h6 {
          /* title properties */
            display: table-cell;
            height: 3em;
            margin: 5px 0 0;
            overflow: hidden;
            padding-bottom: 2px;
            vertical-align: middle;
            width: 130px;
        }

        .relatedsumposts p {
          /* summary properties */
            border-top: 1px solid #0A0A0A;
            border-bottom: 1px solid #0A0A0A;
            color: #summarycolor;
            font-size: 10px;
            height: 4em;
            line-height: 1;
            margin: 5px 0 0;
            overflow: hidden;
            padding: 5px 0 15px 0;
            text-align: left;
        }

        #relatedpostssum {
            background: #121212;
            height: 200px; /* related posts container */
            padding: 5px;
            width: 100%;
        }

        .relatedpoststitle {
            font-size: 19px;
            font-weight: bold;
            border-top: 3px solid #FB8227;
            color: #ccc;
            display: inline-block;
            padding: 5px 10px;
            width: 190px;
            float: left;
            margin: 0px -200px 0px 20px;
            transform: rotate(90deg);
            transform-origin: left top 0;
            -ms-transform: rotate(90deg);
            -ms-transform-origin:left top 0;
            -webkit-transform: rotate(90deg);
            -webkit-transform-origin:left top 0;
           font-family: Gill Sans / Gill Sans MT, sans-serif;
        }
        </style>
        Step 4. Next, search (CTRL + F) for the following code snippet:
        <a expr:href='data:label.url' rel='tag'><data:label.name/></a><b:if cond='data:label.isLast != &quot;true&quot;'>,</b:if>
        And after you found it, add this script just below it:
        <b:if cond='data:blog.pageType == &quot;item&quot;'>
            <script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=readpostlabels&amp;max-results=50&quot;' type='text/javascript'/>
          </b:if>
        The entire fragment should look like this:
                  <b:loop values='data:post.labels' var='label'>
                    <a expr:href='data:label.url' rel='tag'><data:label.name/></a><b:if cond='data:label.isLast != &quot;true&quot;'>,</b:if>
        <b:if cond='data:blog.pageType == &quot;item&quot;'>
            <script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=readpostlabels&amp;max-results=50&quot;' type='text/javascript'/>
          </b:if>

                  </b:loop>
        Step 5. Finally, find this fragment of code:
        </b:includable>
        <b:includable id='postQuickEdit' var='post'>
        Note: search only the line in red and after you find it, you should see the </b:includable> tag above it

        ! Click on the sideways arrow to expand the code, then scroll down until you reach to the highlighted line !

        Just ABOVE the </b:includable> tag, add the following code:
        <b:if cond='data:blog.pageType == &quot;item&quot;'>
          <div class='post-footer-line post-footer-line-4'>
           <div class='relatedpoststitle'>RELATED POSTS</div>
        <div id='relatedpostssum'>
              <script type='text/javascript'>showrelated();</script>
            </div>
            <div style='clear:both;'/>
          </div>
        </b:if>
        Screenshot

        Step 6. Click on the Save Template button to save the changes and you're done!

        Note: in case you see the 'undefined' message, make sure that you have added the appropriate labels to your posts - which can be found in at least one more post, otherwise the script may not be able to find any related posts for that entry.

        A Simple Related Posts Widget For Blogger

        In the last tutorial, we have seen how to add the Related Posts widget that would show related posts with thumbnails from the same category, based on the given labels, which would appear just at the end of your blog posts. However, maybe some of you would prefer the simple version of this related posts widget that will display only the posts titles.

        simple related posts widget

        If you want to add it, follow the next steps below:

        How to add Related Posts Widget to Blogger

        Step 1. Go to Template > hit the 'Edit HTML' button and click anywhere inside the code area.

        Step 2. Press the CTRL + F keys and type the following tag inside the search box (hit Enter to find it):
        </head>
        Step 3. Just above the </head> tag, paste the following style:
        <b:if cond='data:blog.pageType == &quot;item&quot;'><style type='text/css'>
        #related-posts {
            margin: 15px 5px;
        }

        #related-posts h2 {
            font-size: 27px;
            font-weight: normal;
            color: #fff;
            text-shadow: 1px 0px 2px #888;
            margin-bottom: 0.75em;
        }

        #related-posts a {
            font-size: 13px;
            color: #888;
            text-transform: capitalize;
        }

        #related-posts a:hover {
            text-decoration: none;
            color: #555;
        }

        #related-posts ul {
            list-style-type: none;
            margin: 0 0 0px 0;
            padding: 0px;
            text-decoration: none;
            color: #000000;
        }

        #related-posts ul {
            list-style-type: none;
            background: #f9f9f9;
            border-left: 5px solid #f2f2f2;
        }

        #related-posts li {
            padding: 10px;
            line-height: 1.4;
            border-bottom: 1px dotted #E2E2E2;
        }

        #related-posts li:hover {
            background: #F4F4F4;
        }
        </style>
        <script type='text/javascript'>
        var relatedpoststitle=&quot;Related Posts&quot;;
        </script>
        <script src='http://helplogger.googlecode.com/svn/trunk/related_posts.js' type='text/javascript'/>
        </b:if>

        Customization:

        To change the size (27px) and color (#fff) of 'Related Posts' title, change the values in red. For the related post link color, replace the #888 value in green.
        To change the background color, replace the #f9f9f9 hex color in red (you can use this Color code generator to pick your favorite color). For the background color on mouseover, change the #F4F4F4 value in red.

        Step 4. Now find (CTRL + F) this line below (there will be two lines like this, you should stop at the second one):
        <div class='post-footer'>
        Step 5. Just above it, paste the code below:
        <b:if cond='data:blog.pageType == &quot;item&quot;'><div id='related-posts'> <b:loop values='data:post.labels' var='label'> <b:if cond='data:label.isLast != &quot;true&quot;'> </b:if> <b:if cond='data:blog.pageType == &quot;item&quot;'> <script expr:src='&quot;/feeds/posts/default/-/&quot; + data:label.name + &quot;?alt=json-in-script&amp;callback=related_results_labels&amp;max-results=6&quot;' type='text/javascript'/></b:if></b:loop>
        <script type='text/javascript'> var maxresults=5; removeRelatedDuplicates(); printRelatedLabels(&quot;<data:post.url/>&quot;); </script><a style="font-size: 9px; color: #CECECE; float: right;" href="http://helplogger.blogspot.com/2012/04/simple-related-posts-widget-for-blogger.html" rel="nofollow" >Simple Related Posts Widget</a></div></b:if>
        Note: To change the number of maximum related posts for each label, change the "5" parameter from max-results=5

        Step 6. Save the Template and visit your blog > click on any of your posts to see this simple related posts widget in action. Enjoy!