Displaying Comment Number Next to Posts
A lot of people have commented on my new design how they love the comment bubble next to the post title. It’s a great way to foster communication and showcase how many people are talking on your site. So, if you want to add the same functionality to your site, here is the fastest way to do it!
First, you should note in your “index.php” file some code that looks something like this:
<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
To break that down, this is a H2 that inserts an automatic link to the post (<?php the_permalink() ?>) and automatically grabs the title from the post (<?php the_title(); ?>).
To put this in your own blog, ou can either start with your own comment bubble design or grab this one:
[link to comment bubble]
I’ve included the PSD so you can change the color as you need to. You can either add in a background color or save it as a PNG file with transparency – it works either way. Save and upload your comment bubble (JPG, PNG, or GIF only!) either via FTP or the Media Uploader and save the hyperlink – you’ll need it in a second. Head into your theme editor and look for the above code. Right above it, insert this code:
<div class="commentbubble"><?php comments_number('0', '1', '%'); ?> </div>
To clarify, this adds a div container with the “commentbubble” and inserts the code to call the comments. The ‘%’ is a variable number that calls any number that’s not 0 or 1.
Finally, add the CSS into your stylesheet:
.commentbubble {
background-image: url(URL-GOES-HERE);
height: 37px;
width: 49px;
color: REPLACE WITH COLOR;
font-size: 30px;
text-align: center;
padding-top: 5px;
margin-right: 13px;
float:left;
}
Save the edits, and preview. It should put the comment bubble right next to the title. If you are having trouble having your content text or pictures wrapping around the bubble with the title, right after the commentbubble div, put this code:
<div style=”clear:both”></div>
This is a clearing div that will stop the text-wrapping.
December 3rd, 2009 at 5:55 am
[...] Display your comment count prominently. I can’t explain this, but I can tell you that since I started displaying the comment count next to my post titles, the number of my comments has increased dramatically. If the number is low, people want to jump in and be among the first to comment. If the comment count is high, readers think the topic is hot and want to get in on the action. Either way, you win. (I did this on my WordPress blog by modifying some code originally posted by Mitch Canter.) [...]
December 5th, 2009 at 1:26 am
Good stuff here. I've never really considered this but I can see the reason. Just like digg the momentum builds as users see more diggs or ratings.
December 5th, 2009 at 8:26 am
Good stuff here. I’ve never really considered this but I can see the reason. Just like digg the momentum builds as users see more diggs or ratings.
December 14th, 2009 at 11:20 pm
This was very helpful, thanks for posting it – it'd be great if your links were updated though
Also, if anyone's having trouble with the comments_number function, there's another one you can also use called get_comments_number – you'll have to use an echo before it.
God bless
December 15th, 2009 at 6:20 am
This was very helpful, thanks for posting it – it’d be great if your links were updated though
Also, if anyone’s having trouble with the comments_number function, there’s another one you can also use called get_comments_number – you’ll have to use an echo before it.
God bless
December 15th, 2009 at 6:20 am
This was very helpful, thanks for posting it – it'd be great if your links were updated though
Also, if anyone's having trouble with the comments_number function, there's another one you can also use called get_comments_number – you'll have to use an echo before it.
God bless
December 15th, 2009 at 7:22 pm
I loved your tutorial <3 Worked out great. Going to use this to many things
Thanks !
December 15th, 2009 at 7:22 pm
I loved your tutorial <3 Worked out great. Going to use this to many things
Thanks !
June 30th, 2010 at 10:19 pm
This was just the tutorial I was looking for–thanks so much! Can you tell me how to get the comment bubble to link to the comments section for that post? (So people can click on the comment count bubble, go to the comments for that specifis post and then leave a reply.) Thanks.
November 13th, 2010 at 8:44 pm
does this work for Blogger??
November 13th, 2010 at 8:44 pm
does this work for Blogger??
April 26th, 2011 at 8:32 pm
Link to the PSD seems to be gone. Any chance of getting that back?
April 28th, 2011 at 7:08 pm
great post. I look forward to making my own comment box.
December 6th, 2011 at 9:57 pm
Is the link to the comment bubble gone? I don’t see it.