Grid Layout For the Popular Posts Widget

Grid Layout For Popular Posts BloggerA few days back, I published the JavaScript version  of the Recent Posts widget, and I loved the Grid Layout of the Widget. One of the most popular Widgets used by Bloggers is Blogger’s Official Popular Post Widget. So I decided to edit the gadget, and give it the Grid Style.

How does the Gadget Look like after tweaking it?

image image

So Here are the Steps to make your Popular Posts Widget act like an Image Grid

1. Go to the Layout Page and add the Popular Posts Gadget, if you haven’t already added it.

image

2. Edit the Gadget Settings so that it displays the Thumbnails and not the Snippet

image

3. Now Go to Template/Design > Edit HTML . DO NOT Click on the Expand Widget Templates checkbox. Leave it unchecked, and look for  PopularPosts1 (Do a Ctrl +F to find it in your template) and you will get some line like this

<b:widget id='PopularPosts1' locked='false' title='Popular Posts' type='PopularPosts'/>

4. Change This line to

<b:widget id='PopularPosts1' locked='false' title='Popular Posts' type='PopularPosts'>
<b:includable id='main'>
  <b:if cond='data:title'><h2><data:title/></h2></b:if>
  <div class='widget-content popular-posts'>
    <ul>
      <b:loop values='data:posts' var='post'>
      <li>
        <b:if cond='data:showThumbnails == "false"'>
          <b:if cond='data:showSnippets == "false"'>
            <!-- (1) No snippet/thumbnail -->
            <a expr:href='data:post.href'><data:post.title/></a>
          <b:else/>
            <!-- (2) Show only snippets -->
            <div class='item-title'><a expr:href='data:post.href'><data:post.title/></a></div>
            <div class='item-snippet'><data:post.snippet/></div>
          </b:if>
        <b:else/>
          <b:if cond='data:showSnippets == "false"'>
            <!-- (3) Show only thumbnails -->
            <div class='item-thumbnail-only'>
                <div class='item-thumbnail'>
   <a expr:href='data:post.href' expr:title='data:post.title'>
    <b:if cond='data:post.thumbnail'>
                    <img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
       <b:else/>
        <img alt='' border='0' expr:height='data:thumbnailSize' src='...' expr:width='data:thumbnailSize'/>
       </b:if>
                  </a>
                </div>         
             </div>
            <b:else/>
            <!-- (4) Show snippets and thumbnails -->
            <div class='item-content'>
              <b:if cond='data:post.thumbnail'>
                <div class='item-thumbnail'>
                  <a expr:href='data:post.href' target='_blank'>
                    <img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
                  </a>
                </div>
              </b:if>
              <div class='item-title'><a expr:href='data:post.href'><data:post.title/></a></div>
              <div class='item-snippet'><data:post.snippet/></div>
            </div>
            <div style='clear: both;'/>
          </b:if>
        </b:if>
      </li>
      </b:loop>
    </ul>
    <b:include name='quickedit'/>
  </div>
</b:includable>
</b:widget>

5. Save your Template

6. Now Go to Template Designer > Advanced > Add CSS and paste the following CSS snippet there, and apply to your Blog

.popular-posts .item-thumbnail{float:left;}
.popular-posts ul{padding-left:0px;}
.popular-posts ul li {list-style-image: none;list-style-type: none;display:inline;}

The image URL present in the Widget Code is the Default Thumbnail which will be displayed if the post doesn’t have a thumbnail associated with it. You can modify it to get a custom default thumbnail. You can spice up the CSS to make the grid look more eye catching. I would leave that to you :)

Reverting Back to the old one

If you are not satisfied by the way it looks, then revert it back. Here are the steps:

  1. Just Remove the Popular Posts Widget from the Layout Page.If you need the original version, then add it back again
  2. Remove the CSS which you added to Template Designer > Advanced > Add CSS
  3. That’s it.

I think that this Hack would work out well on Recipe and Photography Blogs. Try it out, and let me know if it is useful :)

86 comments :

  1. how to make a popular posts widget like on this blog?

  2. What i noticed on all of the tutorials here is that there is no demo version. Its really hard to do it then at the end i will just remove it because i do not want the looks. Just an opinion :)

  3. nice dude, i want to ask u something, is there any option for showing populer post widget result 20 or 25 instead of 10 ?
    please write back if you know how to do this, thanks

  4. Anne Lyken-GarnerSeptember 5 at 4:40 PM

    This is great. Your tutorials are always easy to follow, even for non-techies like myself.

  5. Thanks for the sharing.It made my Blog more attractive. But I can not find a way to give a headline of the icons in the popular post. Is there any way to give a headline.

  6. nice snippet master...
    i like it ;)

    keep creativity master :D

  7. hi Anesh welcome back to blogger. I made some popular post modification

  8. hi pls put some screen shots of the tricks so that users will get idea exactly how it looks and thanks for sharing ur all nice tricks they are really very useful for bloggers

  9. hi anesh I made modification of popular post with animation at Popular Post using Easy Slider

  10. Brafoo Nice. Beautiful

  11. @Abu - nice one dude. would look better with some slider which takes up square images

  12. just share, for full stylish...
    on CSS side add it...

    .popular-posts ul li img {-moz-border-radius: 5px;-webkit-border-radius: 5px;border-radius: 5px;-webkit-transition: all 0.3s ease;-moz-transition: all 0.3s ease;transition: all 0.3s ease;border: 2px solid #CCC;}
    .popular-posts ul li img:hover {border:2px solid #BBB;-moz-transform: scale(1.3) rotate(-90deg) ;-webkit-transform: scale(1.3) rotate(-90deg) ;-o-transform: scale(1.3) rotate(-90deg) ;-ms-transform: scale(1.2) rotate(-90deg) ;transform: scale(1.3) rotate(-90deg);}

    you can add more variety like width, height, padding or etc for img.
    look for result...hihihi

    Cheers^^

  13. Thannksssssss Its Awesome Widget Thannks Again........:)Helped A Lot

  14. Thanx a lot bro.. i used it in my blog
    its working but a very small bug im seeing there is that upper row us not well aligned. you can check that out .. and please suggest me some solution for this.

  15. @Salaria - dude, you forgot to add the CSS mentioned in the post.

    1. Thanks brother.. its all done! :)

  16. nice tips..but i like if it show how many hits and got some description on it.

  17. Awesome post! Love this. Thanks for sharing your code. :) <3

  18. Yes yes, we need more good widgets and tools like this !!

  19. What a great article. Great information. Thanks for sharing.

  20. Hi,great widget.I want to change the width and the height of the thumbnails.I want three at a row like yours.Now it is like this on my blog
    Thanks

  21. When I put the code in the "add CSS" box, it lines up everything perfectly but then I view my blog and it is all off center again. Any suggestions?

  22. Amazing tweak! Btw is there any way to make the thumbnails get all image content? My images are 600x90px and it uses a small area to create the pupular thumb, i wish i could make it two colums of 140*70px thumbs with the entire image content.

  23. I can't have a 3 by 3 grid in my blog, i tried expanding the width of my template.

  24. @MSN Scenes - I Think this will do our job :

    Replace
    <b:if cond='data:post.thumbnail'>
    <img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
    <b:else/>
    <img alt='' border='0' expr:height='data:thumbnailSize' src='...' expr:width='data:thumbnailSize'/>
    </b:if>

    with

    <script type="text/javascript">
    document.write(bp_thumbnail_resize_popular("<data:post.thumbnail/>"));
    </script>
    <noscript>
    <b:if cond='data:post.thumbnail'>
    <img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
    <b:else/>
    <img alt='' border='0' expr:height='data:thumbnailSize' src='...' expr:width='data:thumbnailSize'/>
    </b:if>
    </noscript>

    paste this code

    <script type="text/javascript">
    //<![CDATA[
    function bp_thumbnail_resize_popular(image_url)
    {
    var image_size=450;
    var show_default_thumbnail=true;
    var default_thumbnail="...";
    if(show_default_thumbnail == true && image_url == "") image_url= default_thumbnail;
    image_tag='<div style="width:140px;overflow:hidden;float:left"><img src="'+image_url.replace('/s72-c/','/s'+image_size+'/')+'"/></div>';
    if(image_url!="") return image_tag; else return "";
    }
    //]]>
    </script>

    above

    <b:loop values='data:posts' var='post'>

  25. @MSN Scenes - When i said replace or "paste above" , I'm referring to the code in this post.

  26. @Kevin - Add this CSS :
    .popular-posts img{width:46px;height:46px;}

  27. Worked like a charm!!! I changed some values to fit my layout but Its looking amazing now hehe.

    Thanks for the nice script and so quick answer!

  28. Never mind.

  29. Didn't work for me, it staggered the thumbnails.

    1. That's what it did to me too!!

  30. Hey i want a 3x3 grid for my popular posts i am non techie person can you help me with the css coding?

  31. @Annika , @Anusha - can't help you without seeing it live on your blog.
    add it first and then i would be able to help you out with the CSS.
    you can catch me here in the comments.

  32. Ooo I just love this!! I've got it installed ok on my blog but my top 3 thumbnails are staggered - the other 6 are lined up just fine. My blog is: would you have any suggestions? Thank you!

  33. Hi Aneesh.
    I got a little problem about it.
    Some view my picture does not appear when it should be there. Like the show "No Image Available".
    Will you help me, please?

    1. That is because the post image is not uploaded on your blog it's only embedded

  34. hello bloggerplugin i am having problem adding this widget to my blog..

    the first line images are not inline i want them streignt can u help me...thanks

  35. errrr... if not change also can rite ?

  36. hi, first great work!
    my question can i do that also with the recent post widget?
    Regards

    i tried it out...hi

  37. i cudnt make this work on mine? It appears html error when i try to save my template. I did close all tags. But still its no luck.

  38. @ Aneesh. It does not work if your picture is not hosted in your blog. I just experienced it. So i uploaded them into my blog. If that was your case, i think it doing so will work it.

  39. I can't add this code to my page.
    Error Message:
    The element type "b:section" must be terminated by the matching end-tag "".

    Please help me ?

  40. Thank you very much
    You are the best

  41. @Hola VN
    i got ur problem, i think that you just add the code after
    but you didn't change the code above, so look the diffrent both code below

    and

    see, second code doesnt have "/"

  42. @aneesh: Hi! Awesome grid! Is there a way to make it show 12 thumbnails? Thanks!

  43. do u have a widget that might show the popular posts as an automatic slide show ?

  44. Спасибо!

  45. only show 10 post how increase post number widget allow only 10 post please replay me

  46. I,m very happy now with my popular-post widget. Hoooooooooooooo!!!
    please give me information to make slideshow in header. Please,please.

  47. only show 10 popular post. how increase post number, widget allow only 10 post .any idea ..?
    please replay me

  48. cool...Nice Step By Step Information...

  49. great widget. Thanks!

  50. Do you have any idea how I could make the popular posts widget show up on a page by myself instead of on a sidebar? No matter what I try, copying+pasting the widget code etc, I can't seem to get it to appear on a Page.

  51. @Laura - It's not that easy. I can try to help you out :-).
    You can drag and drop the poplular posts gadget to the somewhere above the blog post gadget so that it looks better.
    The second thing that you have to do is to display the widget only on a particular page and not anywhere else.

    Look closely at the bolded lines in the following code. I'm restricting the popular posts gadget to your About Me page.


    <b:widget id='PopularPosts1' locked='false' title='Popular Posts' type='PopularPosts'>
    <b:includable id='main'>

    <b:if cond='data:title'><h2><data:title/></h2></b:if>
    <div class='widget-content popular-posts'>
    <ul>
    <b:loop values='data:posts' var='post'>
    <li>
    <b:if cond='data:showThumbnails == "false"'>
    <b:if cond='data:showSnippets == "false"'>
    <!-- (1) No snippet/thumbnail -->
    <a expr:href='data:post.href'><data:post.title/></a>
    <b:else/>
    <!-- (2) Show only snippets -->
    <div class='item-title'><a expr:href='data:post.href'><data:post.title/></a></div>
    <div class='item-snippet'><data:post.snippet/></div>
    </b:if>
    <b:else/>
    <b:if cond='data:showSnippets == "false"'>
    <!-- (3) Show only thumbnails -->
    <div class='item-thumbnail-only'>

    <div class='item-thumbnail'>
    <a expr:href='data:post.href' expr:title='data:post.title'>
    <b:if cond='data:post.thumbnail'>
    <img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
    <b:else/>
    <img alt='' border='0' expr:height='data:thumbnailSize' src='...' expr:width='data:thumbnailSize'/>
    </b:if>
    </a>
    </div>
    </div>
    <b:else/>
    <!-- (4) Show snippets and thumbnails -->
    <div class='item-content'>
    <b:if cond='data:post.thumbnail'>
    <div class='item-thumbnail'>
    <a expr:href='data:post.href' target='_blank'>
    <img alt='' border='0' expr:height='data:thumbnailSize' expr:src='data:post.thumbnail' expr:width='data:thumbnailSize'/>
    </a>
    </div>
    </b:if>
    <div class='item-title'><a expr:href='data:post.href'><data:post.title/></a></div>
    <div class='item-snippet'><data:post.snippet/></div>
    </div>
    <div style='clear: both;'/>
    </b:if>
    </b:if>
    </li>
    </b:loop>
    </ul>
    <b:include name='quickedit'/>
    </div>
    </b:if>
    </b:includable>
    </b:widget>

  52. hello Mr Aneesh sorry for being irrelevant but could you please tell me how to manually RTL(right to left) popular post widget (by manipulating css or/and html on template code), i am running an Arabic blogspot blog but when i activate the popular post widget the items thumbnail keep floating on the left!
    i hope you reply on my request as soon as possible.
    thank you

  53. Hey how do i get the popular post widget to appear on in the center of the page rather then in the side bar. i tried dragging it to the center but the images dont arrange in line. Could you help us out.
    THANKS

  54. i have a problem that the image cannot line up well, even though i was pasted the CSS. HELP!

  55. Paulo Emmanuel MarasiganJanuary 22 at 3:21 PM

    it won't show any image thumbnail.. is there a way to change the alternative image if there is no image at all?

  56. because of this, I found the tweak that I was looking for. Thanks! :)

  57. Why look at my blog is not flat

  58. Isolated Existence.January 27 at 3:00 AM

    I added this but the first line is staggered. Anyone knows how to fix it? Thanks!

  59. Isolated Existence.January 27 at 3:34 AM

    Never mind, fixed it. Went to the last step (Add CSS), changed it to float:right on the first line .popular-posts .item-thumbnail{float:left;} then changed it back to left and it align it perfect.

    Thanks for the great widget!

  60. hei admin Blogger Plugin

    I want to ask a little to you, the point No.4, after I save the template. error message appears like this
    "Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
    XML error message: The element type "b:section" must be terminated by the matching end-tag ""."

    I need your help, Pls reply :( :( :(,

    thank's before and nice to meet you,, keep blogging !!!

  61. Thanks, work great for my site

  62. Great example photos! ; )

    I made the modifications but the thumb-nails displayed in a "stepping" thumbnail. That is, each one seemed to go down one pixel. Could it be that my side-bar is not wide enough?

    Would love to use this!!!


    Thanks,

    L
    Thanks,

    L

    1. ;)..
      add it first and then i would be able to help you out.

  63. I fixed mine using the same steps that "Isolated Existence" used to fix his.

    Only problem is that I have an image in front of the blog post title and the HTML for that image comes up as part of the post title when you hover the mouse over the popular post.

    Can you make the widget ignore the code and only show the actual post title?

    1. the widget just uses the post title. I guess you have messed up the HTML codes and that is the reason why an image tag is appearing in the title of the link.

  64. The HTML isn't messed up, I paste the HTML for the image into the post title and then I type in the post name. That way the favicon is in front of the post title.

    1. hmm that's a weird way of doing it. You can easily do this by adding some small CSS snippet rather than messing up post titles :-).

  65. I know there must be a way but I dont know how

    1. Add this to Template Designer > Advanced > Add CSS

      h3.post-title {
      background: url("...") no-repeat scroll left center transparent;
      padding-left: 24px;
      }

  66. Thanks that worked great, but I need a space between the pic and the post title. I tried to add some code to yours but it didnt work.

    1. i guess you fixed it :-) you have to increase the left padding to do that.

  67. This widget worked great! Thanks!

  68. I changed the code to:

    h3.post-title {
    background: url("...") no-repeat scroll left center transparent;
    padding: 0px 10px 0 35px;
    }

    thanks again.

  69. grosir tas murahMarch 5 at 1:45 PM

    thankyu.. informative.. ;)Great post!.. keep the posts coming & i will keep reading them. thank for help them. Great blog dude! I just linked to this post on my Delicious. Keep it up!

  70. Thank you so much for this! I was searching for this for blogger and I am just starting out.

    Hoping someone can give me a hand. I love the grid but they are staggered as well. I tried the left right left align but that did not work. Any ideas?

    Also wondering how to get it to left align with the rest of the sidebar so the images are not sticking into the main body.

    Thanks so much in advance!! This is great help for a blog newbie! =)

  71. This comment has been removed by the author.

  72. Awsome widget... ^_^
    Thanks.. I will try it

  73. it's work! thanks master

  74. Thanks bro
    it worked

  75. LifewithspicesApril 2 at 10:37 AM

    Jus brilliant it works awesome..Thank you!!

  76. Wonderfulll!
    Thanks alot.

  77. it just doesn't work for me - images are all over the place - want it to be formatted the same as my instagram widget

    thanks

  78. Nice style, but image not show on my blog