A fun part of customizing WordPress themes is designing a comments format which complements the rest of the site. Here are three examples from recent projects, including code samples and downloads to the original .PSDs:
- Green Gravatars
This comment style was part of a very green-and-beige environmental blog which since received a makeover. It requires the gravatar plugin and three different images: the scanlines, the clock and the gradient, which can be exported from your .PSD.
First, we’ll need to first edit the ordered-list section of the “comments.php” template:
<ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <cite> <img src="<?php gravatar("R", 32); ?>" alt="" /> <span class="author"><?php comment_author_link() ?></span><br /><span class="time"><?php comment_time() ?></span> on <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?></a> <?php edit_comment_link('edit',' ',''); ?> </cite> <div class="commenttext"><?php comment_text() ?></div> <?php if ($comment->comment_approved == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> </li> <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?> <?php endforeach; /* end for each comment */ ?> </ol>Aside from a few images, the rest of the styling is accomplished with CSS:
ol.commentlist { margin:0; padding:0; } .commentlist li { list-style:none; margin-bottom:14px; } .commentlist cite { padding: 7px; display:block; font-style:normal; background:url(http://www.yoursite.com/images/bg_comments2_cite.gif); border-top:1px solid #d6e4c1; border-bottom:1px solid #779d42; color:#596e3b; } .commentlist a:link, .commentlist a:visited { color:#596e3b; } .commentlist a:hover, .commentlist a:active { color:#8ec343; } .commentlist cite img { padding:1px; border:1px solid #aab59a; float:left; margin-right:9px; } .commentlist .author { font: small-caps bold 1.2em Georgia, "Times New Roman", Times, serif; text-decoration:underline; } .commentlist .time { background: url(http://www.yoursite.com/images/bg_clock.gif) no-repeat 1px; padding-left:13px; } .commenttext { background: #9bc561 url(http://www.yoursite.com/images/bg_comments2_text.jpg) repeat-x bottom; border-top:1px solid #c5f386; padding: 0 20px 10px 20px; color:#fafcf6; }Keep in mind, each of these examples uses ems for font sizing, so your existing CSS may need to be tinkered with to match the screenshot above.
- The Speech Bubble
I designed this comment style for my company’s website. It requires two images, the quote marks and the little curl. The relevant template code looks like this:
<ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <div class="quote"><?php comment_text() ?></div> <?php if ($comment->comment_approved == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> </li> <cite><?php comment_author_link() ?> on <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_date('F jS, Y') ?> at <?php comment_time() ?> <?php edit_comment_link('edit',' ',''); ?></a></cite> <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : ''; ?> <?php endforeach; /* end for each comment */ ?> </ol>And here is the CSS:
.commentlist .quote { background:url(http://www.yoursite.com/images/bg_quote.gif) no-repeat top right; } .commentlist li { padding: 5px 18px 22px 18px; margin-top:15px; background:#454545 url(http://www.yoursite.com/images/bg_commentlist.gif) bottom no-repeat; color:#e4edee; } .commentlist cite { display:block; font-style:normal } .commentlist cite a:link, .commentlist cite a:visited { color:#88e5f0; text-decoration:none; } .commentlist cite a:hover, .commentlist cite a:active { color:#FFF; text-decoration:underline; } - Alternating Arrows
This comment styling originated from a music magazine I mocked up but never quite launched (so feel free to use it). I don’t always make use of the “.alt” class for comments, but it’s handy here for making the arrow and colors alternate. The images used are two different “paint” effects, the diagonal pattern, the chainlink and two kinds of arrows.
Here is the template code:
<ol class="commentlist"> <?php foreach ($comments as $comment) : ?> <li <?php echo $oddcomment; ?>id="comment-<?php comment_ID() ?>"> <div class="commenttext"> <cite><?php comment_author_link() ?></cite> <?php comment_text() ?> <span class="date"><img src="/images/commentlink.gif" alt="" /> <a href="#comment-<?php comment_ID() ?>" title=""><?php comment_time() ?> on <?php comment_date('n/j/y') ?></a></span> <?php edit_comment_link('edit',' ',''); ?> </div> <?php if ($comment->comment_approved == '0') : ?> <em>Your comment is awaiting moderation.</em> <?php endif; ?> </li> <?php /* Changes every other comment to a different class */ $oddcomment = ( empty( $oddcomment ) ) ? 'class="alt" ' : '';?> <?php endforeach; /* end for each comment */ ?> </ol>And here is the CSS:
ol.commentlist { margin:0; padding:0; } .commentlist li { margin-bottom:8px; background: #60360b url(http://www.yoursite.com/images/comment_arrows.gif) bottom no-repeat; color:#FFF; list-style:none; width:413px; } .commentlist .commenttext { background:url(http://www.yoursite.com/images/bg_paint.gif) no-repeat; padding:22px 22px 50px 22px; } .commentlist cite { display:block; color:#FFF; font-weight:bold; text-transform:uppercase; font-style:normal; background:url(http://www.yoursite.com/images/bg_cite_arrows.gif) bottom repeat-x; padding-bottom:12px; font-size:1.1em; } .commentlist a:link, .commentlist a:visited { color:#fff9b9; } .commentlist a:hover, .commentlist a:active { color:#FFF; } .commentlist .date { background:#930e27; padding:3px; } li.alt { background:#836241 url(http://www.yoursite.com/images/comment_arrows_alt.gif) no-repeat bottom; } li.alt .commenttext { background:url(http://www.yoursite.com/images/bg_paint_alt.gif) no-repeat; } li.alt .date { background:#67421c; padding:3px; }
6:17 am
Thanks for sharing your work.
9:31 am
knlknlknl
6:18 pm
cute !!
3:15 am
thnks
8:47 am
Thanks ! It will help a lot :)
2:28 pm
thank u for sharing !! :D
12:50 am
nice
6:53 am
Thanks for this :)
6:47 pm
asasdasda
4:21 pm
yay!
9:16 am
Thx mate for the tutorial. But please check your code. There are some typos in it.
Ex: id=”comment-”
should be
” id=”comment-”
1:04 pm
There is no error in the code , or possible already fixed.
9:21 pm
Beautiful styling! I’m determined to make this work, though I must admit I’ve spent quite a while trying to identify the errors. I keep getting Parse Error codes and the only changes I made was add this code. *sigh*
8:29 pm
dddd
3:00 pm
I just wanted to send you a quick hello and a thank you for this very useful article. I found myself searching through the web looking for some kind of tutorial, or at least a website, that covered the structure of the comments.php.
Feel welcome to take a peek (and more than welcome to have a bash at making author comments stand out; my style.css has a worrying mish-mash of your code and the original that causes headaches).
I digress. Thanks once again for the useful guide. Credit where credit’s due.
3:18 am
Using white-space in comments?
Test 2 “nbsp”
2:39 pm
how would you do the comments so that the comments and trackbacks are seperate?
12:34 pm
how do you do italics
8:40 am
test
test
8:41 am
test
test
1:34 am
Darren, you rock! Thank you very much for the tutorials. More power to you!
4:40 am
This post is a great help to me. Thanks for all.
5:25 am
Hi, I have a typepad account and I was wondering if anyone new of a tutorial that went step by step to show how to style the comment section. The above is great but I’m a complete novice and need a bit more explaining. Thanks so much !
9:18 am
Darren, this is a huge help to get on the way understanding the inner working of comments. I have trashed dozens of themes in my time because I didn’t like how the comments and input boxes were styled.
One question: How can you distinguish between the author/blog representative and other commenters to allow a visitor to see that particular comments are the blog’s stance? I think that would be a terrific modification to the gravatar style (i.e., change the background color for the blog owner).
Thanks!
10:30 am
Very nice blog design and layout!
1:52 am
Thanks so much for taking the time to write this post. I was able to implement it with no problems whatsoever. Big up!
4:04 pm
Hi there,
I am trying to implement this idea in my website but for some reason the numbers are not showing up against the comments. What code would allow me to do this or what code might be preventing this?
Thanks
4:16 pm
Thanks for your great help!
8:49 am
Great!!
9:32 pm
Óõ òû ,êë¸âî !
6:07 am
thank you i am downloaded good job.
3:11 am
Great work,Thank you for tharing it!
5:55 am
The Info very help me, thank a lots.
1:27 pm
Thanks!
3:29 pm
Thanks for your great help!
4:47 am
Welcome to http://www.yogawww.com . We provide for all your chinese-cross-stitch,cross-stitch, yoga videos, yoga books, yoga clothing, yoga mats and the latest yoga news,yoga classes yoga photo,
8:11 am
thank you…
4:00 pm
Hello -
Thanks for these! They are nice, I was wondering – I’d like to use the last one, but when an author posts a comment (me), I’d like it to show a different styled comment. Is this possible? If so, how?
Hope you can help me out – Thx,
Josh Budde
8:16 am
@josh: this technique works well for me.
10:59 am
Ух ты, здоровÑко!
11:53 am
Мне Ñта инфа пригодитÑÑ!
4:16 am
Hi…I love these comment formats, but I guess I am not skilled at WP and css yet to get them to work.
I wanted to use the speech bubble design. I got the images loaded and what not, but a lot of the style from my original comment formatting was still there. I replaced the in my comment.php file and added the css to my style.css file.
I guess I need to delete something else from one or both of those files? I am using Revolution Pro Media them.
Actually, I might prefer the green gravatar style commenting style as well.
I’d gladly link back to or digg or stumble anyone who can help me get either of those comment systems working.
Thanks.
7:10 am
Thank u 4 sharing this!! it will help a lot on my blog! Thanks again! (^_^)
3:28 pm
Nice avatar!
9:49 pm
This is what I’ve been looking for so far!!!
Thanks a lot for sharing your stuff :b
6:23 am
Hi..and sorry, but my english´s very bad.
Many thnxs for share u work my friend. Very usefull for me. Only one question..how to “alt” commentlist cite?
Thanks anyway
7:30 am
Np now..i added:
<cite >
and “cite.alt” into css stylesheet, and work fine now.
Thanks anyway
5:40 am
Great work
Thank you for tharing it …!
5:41 am
thank you…
2:50 pm
This is extremely useful, since WordPress has picked up speed to be the complete CMS system for websites. It is now not uncommon to see a whole website right on the WordPress platform.
1:54 am
thanks…
4:17 pm
Wow Cool !
Super Man
Nice Site
7:29 pm
Thanks so much for taking the time to write this post. I was able to implement it with no problems whatsoever. Big up!
7:24 am
Thanks for giving information about Word Press. It is very helpful for us
2:09 am
je vous remercie pour ces imaes :)
12:22 am
can you let us know how to paginate a wordpress theme like digg?
plleaseeeeeeee!!!!!!!!!!!!!!!!!!!!!
5:04 pm
How would you go about displaying the author’s comments in a different style?
Thanks!
12:35 am
Can you just add the design to my website and make the changes I want so I don’t mess up your lovely design? This is a wonderful theme and I love it, but I feel so confused by it.
Nancy
6:50 pm
[...] Styling Your WordPress Comments [Tuto] Voici un tutoriel (+ressources à télécharger) qui vous donne 3 manières de faire une mise en forme originale
6:50 pm
thank you
6:45 am
Great dude!
I’m gonna be doing a makeover to my comments section thanks to your tutorial.
Thanks a lot!
11:36 am
Nice Thanks!
8:37 am
Thanks so much for taking the time to write this post. I was able to implement it with no problems whatsoever. Big up!
8:36 pm
Hi Darren,
I have a question on how you achieved the html formatting buttons on your comments form on this page? I’m trying to do something similar & wondered if this were a plugin or your own code?
Any advice would be very much appreciated.
8:37 pm
Hi Darren,
I have a question on how you achieved the formatting buttons on your comments form on this page? I’m trying to do something similar & wondered if this were a plugin or your own code?
Any advice would be very much appreciated.
2:15 pm
Thanks Great work!!
8:13 pm
very nice, thank you
9:30 am
This will help a treat ! THanks for sharing… Rob
10:30 pm
thx for this, im gonna test it on my blog, :) !
12:54 pm
Awesome tutor and examples. I choosed green style and implemeted it on my blogs. Thank you for your effort. Keep up writting other tips.
3:14 pm
Thank you i just downloaded it and i liked styling comments would be very useful at my blog.
8:27 am
awesome post! i have styled my comments using your tutorial! :-)
10:27 am
Sweet!!
1:19 am
[url=http://online-seek.net/make-watches/rado-watches-home.html]replica watches corum bridge of gold[/url]
[url=http://online-seek.net/top-replica-warches/watchid674.html]baby g shock watches[/url]
10:59 pm
Helpful. Thanks. I’m also looking for how to add the formatting buttons for comments you use here yourself for those posting comments. ie. bold, italics, link, indent etc.
9:29 pm
thanks u very good..
1:53 am
Beautiful styling! I’m determined to make this work, though I must admit I’ve spent quite a while trying to identify the errors. I keep getting Parse Error codes and the only changes I made was add this code. *sigh*
1:54 am
very helpful reading, thanks
7:08 am
Thank you for the info, I’m planning to improve my blog.
8:33 am
Thanks for this, we spend several hours today fixing the look of our comments, untill we stumble on your page without any luck!
If you should have new designs later on, please inform us about that
Regards
Morten
5:54 pm
Hi, I have a typepad account and I was wondering if anyone new of a tutorial that went step by step to show how to style the comment section. The above is great but I’m a complete novice and need a bit more explaining. Thanks so much !
2:40 am
Thanks for sharing….great
11:24 am
Cool!
Do you happen to have anything for styling an “About This Author” section, that could be added to the end of a post?
Just wondering…
1:36 am
I think I got some result. Thank you here. Great job on the theme.
Thanks for sharing.
7:18 am
hi i want to have my comments across 4 columns do you have any examples of how to do this? Thanks
1:59 pm
Cool! I like the second one. Thanx buddy!
8:28 pm
Nice tutorial. I’m using Cutline’s 1.4-3ColumnSplit theme and trying to implement the Alternating Arrows comment style but I’m not sure where to add the template code within my comments.php. Any assistance will be appreciated.
Thanks
12:00 am
Thanks so much for taking the time to write this post. I was able to implement it with no problems whatsoever. Big up!
5:08 am
Thanks for your great help!
4:12 pm
Thanks ! It will help a lot
9:02 am
hi very good thank you
6:56 am
thank you very good…
11:42 am
Very useful info. Thanks for sharing.
11:37 am
Is the function “emptyempty” (Line 15) supposed to just be “empty”? That change worked for me.
11:50 am
Good question, that code is about 2 years out of date. There has since been a comment_class function that generates classes to allow alternate li styles.
9:39 pm
Small edit required in first comment box css:
background: #9bc561 url(http://www.yoursite.com/images/bg_comments2_text.jpg) repeat-x bottombottom;
Should be:
background: #9bc561 url(http://www.yoursite.com/images/bg_comments2_text.jpg) repeat-x bottom bottom;
missing space between “bottombottom”
:D
3:16 pm
Nice layouts…
5:13 pm
Thanks a lot for the information. I implemented Alternating Arrows within about 2mins. How can I change the font size or type.
Thanks again
5:11 pm
Really nice styles! I like it
2:12 pm
Hi There, Thanks for your posts about styling comments. Here is a puzzler that i’ve been going nuts trying to figure out:
What if you’d like to have the COMMENT META DATA displayed INLINE with the COMMENT like this:
[COMMENTOR NAME HERE: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum non elit dolor, non sodales justo. Donec dictum, diam a aliquet suscipit, lectus mi ultricies nunc, sit amet imperdiet urna dui eu velit. Mauris molestie, libero id eleifend pretium, tellus arcu facilisis eros, sagittis ornare enim est eu mauris. In hac habitasse platea dictumst. Vivamus vehicula DATE | TIME| TRACKBACK LINKS, etc.]
In my text its not so easy to illustrate but I’d like to have the commentor’s name inline with the actual comment. Then maybe the date/time inline on the end of the comment. I’d use CSS to set them off.
Any ideas? I’d greatly apppreciate it. Thanks.
5:53 am
tancks.
This Post Helped me
Good Time
2:37 pm
Thanks ! the speech bubble looks great !
3:01 am
great post bro, keep posting :)
4:51 pm
Great tutorial,Thanks you.
5:41 am
Now that is pretty awesome (: Thank you.
2:01 pm
Thank for great tutorial.
8:20 am
Hi do you have a code for this style for comment :
http://i789.photobucket.com/albums/yy174/crygretll/reactie.jpg
can you mail it to me?
5:49 am
谢谢了!I’m in China
7:35 pm
Great Tutorial. Thank you so much!
11:47 am
Oh! Great!!!
11:22 am
thank for share to us !
5:12 am
Cool !
just wanted to know what extension you are using for putting the code in your posts like that ?
12:54 am
Thanx
3:04 pm
very nice post
thanks
4:26 pm
Nice! Great tips
11:29 am
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddsssssssssssssssssssssssdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
1:30 pm
Thanks for sharing mate, have a great week end!
9:34 am
[blockquote]asdasd[/blockquote]
asdasd
5:28 pm
Hi
Tanx that’s work!
but with a few edit in source
tanx again
6:54 am
Thank you very much
I want to add the avatar (from Gravatar) to the third, Alternating Arrows template. How can I do that ?
Thanx
5:00 am
Thank you very much. I have benifited from this tuturial and applied it in my blog:
http://personal.al-rasid.com/
10:14 pm
Looks great, and thanks for sharing this.
One issue is that in the wordpress discussion settings where it says “break comments into pages with X comments per page” it seems to no longer work with your code. As a result my comments look great, but they will get longer and longer on the one page. Do you have any suggestions for this?
9:16 am
hi how we can add repply link in our blog comment are my comment.php file code is
[sourcecode]
post_password)) { // if there’s a password
if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn’t match the cookie
?>
This post is password protected. Enter the password to view comments.
to “”
<li id=”comment-”>
says on
<a href="#comment-” title=”"> at
:
comment_approved == ’0′) : ?>
Your comment is awaiting moderation.
comment_status) : ?>
Comments are closed.
comment_status) : ?>
Leave a Reply
You must be <a href="/wp-login.php?redirect_to=”>logged in to post a comment.
<form action="/wp-comments-post.php” method=”post” id=”commentform”>
Logged in as <a href="/wp-admin/profile.php”>. <a href="/wp-login.php?action=logout” title=”Log out of this account”>Logout »
<input type="text" name="author" id="author" value="” size=”22″ tabindex=”1″ />
Name
<input type="text" name="email" id="email" value="” size=”22″ tabindex=”2″ />
Mail (will not be published)
<input type="text" name="url" id="url" value="” size=”22″ tabindex=”3″ />
Website
<!–XHTML: You can use these tags:
–><input type="hidden" name="comment_post_ID" value="” />
ID); ?>
[/sourcecode]
9:05 am
Awesome info, thanks! Still pretty new to WordPress but I’m getting through it.
7:06 am
usefull tutorial :) thnx so much..
1:30 am
Testing your comments template =)
3:34 am
how to show a bigger user image?
1:28 pm
Nice styling! I’m determined to make this work, though I must admit I’ve spent quite a while trying to identify the errors. I keep getting Parse Error codes and the only changes I made was add this code. ”sigh”
9:24 am
It’s very nice! I love what you wrote.
I think we can make friends.
1:59 pm
Thank you i just downloaded it and i liked styling comments would be very useful at my blog.
1:28 pm
Thanks so much!
11:02 am
Hi,
Is the code you use for the comments.php file compatible with WordPress 3.0?
It doesn’t seem to work for me…
6:59 pm
Hi! I am making use of the first of these tutorials, but am unable to get it to work due to the use of <img src="” alt=”" />
I am getting an error with this as gravatar is an unknown function. Does anyone have a solution?
10:24 am
thanks, this perfect sharing.i like this website.
8:26 am
Great work
Thank you for tharing it …!
8:26 am
Thank you! Great Post!
12:49 am
Ellerine saglik admin cok guzel olmus paylasim icin tsk ederim
7:27 am
not working :s
9:41 pm
not working with lastest wordpress version >3!
9:34 am
Very nice blog design and layout!
Thanks.
1:02 pm
Your code is good , thank you for sharing I was able to implement it in just a few minutes
1:47 pm
Hey,
So I’ve been trying to use #3 for my comment section but the images aren’t showing up even though I implemented the CSS as shown and uploaded the images to my server. I think it might be a PHP problem since I don’t know exactly where to put the PHP. Can anyone tell me in between which lines should this PHP section go? I think its the most awesome comment box I’ve ever seen! :-) Anyway, thanks for the help
4:05 am
Very interesting.
8:58 am
I have been working with the comments on my page for few days now to make it not so boring. Your tips sounds great and I’ll surely try it. Will this work regardless of the browser we are using?
1:11 pm
very nice and great.. thnk u..
3:55 pm
Darren, Thanks for sharing this! Question, in using the quotes sample, the quote gets cut off if the message is too short (one line). How do I remedy this?
10:42 am
Than ks for your post.
10:03 am
Thank you! Exactly what I was looking for
10:36 am
Glad that I came here from Google. I was looking for some serious comment display modifications on my site.
Thanks Darren.
5:32 am
“the gravatar plugin”
Which 1? There are like 5….
8:22 pm
What do you mean by “we’ll need to first edit the ordered-list section of the “comments.php” template”? Do you mean to input the code or change the code? Also, is it comments.php or comment.php? So far I only found the latter.
5:51 am
ledgend thanks for this!!!
12:04 pm
I have been checking out a few of your articles and i can state pretty nice stuff. I will surely bookmark your blog.
5:13 am
文章可以转载吗
8:40 pm
its awesome. ill be using one of it
3:13 am
Brilliant article!