From wordpress 2.7 version we got the functionality of changing or customizing the comments template as per your theme. As we all know in single.php file we called following function to add comments functionality
<?php comments_template(); ?>
This function basically calls the comments.php file and add the data from wordpress database.
If we check the comments.php file. Usually we are having following content in comments.php file
<?php
// Do not delete these lines
if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
die ('Please do not load this page directly. Thanks!');
if ( post_password_required() ) { ?>
<p>This post is password protected. Enter the password to view comments.</p>
<?php
return;
}
?>
<!-- You can start editing here. -->
<div id="comment">
<?php if ( have_comments() ) : ?>
<h3 id="comments"><?php comments_number('No Responses', 'One Response', '% Responses' );?> to “<?php the_title(); ?>”</h3>
<div>
<div><?php paginate_comments_links(); ?></div>
</div>
<ol>
<?php wp_list_comments('callback=wordpressapi_comments'); ?>
</ol>
<div>
<div><?php paginate_comments_links(); ?></div>
</div>
<?php else : // this is displayed if there are no comments so far ?>
<?php if ('open' == $post->comment_status) : ?>
<!-- If comments are open, but there are no comments. -->
<?php else : // comments are closed ?>
<!-- If comments are closed. -->
<p>Comments are closed.</p>
<?php endif; ?>
<?php endif; ?>
<?php if ('open' == $post->comment_status) : ?>
<div id="respond">
<h3><?php comment_form_title( 'Leave a Reply', 'Leave a Reply to %s' ); ?></h3>
<div>
<small><?php cancel_comment_reply_link(); ?></small>
</div>
<?php if ( get_option('comment_registration') && !$user_ID ) : ?>
<p>You must be <a href="<?php echo get_option('siteurl'); ?>/wp-login.php?redirect_to=<?php echo urlencode(get_permalink()); ?>">logged in</a> to post a comment.</p>
<?php else : ?>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<?php if ( $user_ID ) : ?>
<p>Logged in as <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="Log out of this account">Log out »</a></p>
<?php else : ?>
<p><input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="22" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="22" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> />
<label for="email"><small>Mail (will not be published) <?php if ($req) echo "(required)"; ?></small></label></p>
<p><input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
<?php endif; ?>
<!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->
<p><textarea name="comment" id="comment" cols="100%" rows="10" tabindex="4"></textarea></p>
<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
<?php comment_id_fields(); ?>
</p>
<?php do_action('comment_form', $post->ID); ?>
</form>
<?php endif; // If registration required and not logged in ?>
</div>
<?php endif; // if you delete this the sky will fall on your head ?>
</div>
In the comments loop for showing the comments we used the wp_list_comments() function.
We can customize this function as per our requirment. We can pass the following parameters to this function.
<code> <?php $args = array( 'walker' => null, 'max_depth' => <em>, </em><em>'style' </em><em>=> </em><em>'ul'</em><em>, </em><em>'callback' </em><em>=> </em><em>null</em><em>, </em><em>'end-callback' </em><em>=> </em><em>null</em><em>, </em><em>'type' </em><em>=> </em><em>'all'</em><em>, </em><em>'page' </em><em>=> </em>, 'per_page' => <em>, </em><em>'avatar_size' </em><em>=> </em><em>32</em><em>, </em><em>'reverse_top_level' </em><em>=> </em><em>null</em><em>, </em><em>'reverse_children' </em><em>=> </em> ); ?> </code>
For customizing the comments follwing parameter is important.
callback (string) The name of a custom function to use to display each comment. Defaults to null. Using this will make your custom function get called to display each comment, bypassing all internal WordPress functionality in this respect. Use to customize comments display for extreme changes to the HTML layout. Not recommended.
In my theme I used that in following way. I changed and passed parameter in comments.php file
<?php wp_list_comments('callback=wordpressapi_comments'); ?>
Then Open the functions.php file put following code in that. This code I am using as per wordpress api.
function wordpressapi_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div>
<?php echo get_avatar($comment,$size='32',$default='<path_to_url>' ); ?>
<?php $user_name_str = substr(get_comment_author(),0, 20); ?>
<?php printf(__('<cite><b>%s</b></cite> <span>says:</span>'), $user_name_str) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<div><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?></div>
<?php comment_text() ?>
<div>
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
</div>
<?php
}
Many times some people add the full URL of website in the name parameter. That time showing author name of comment writer is looks so ugly. So I used following trick in this function. Using this line of code we can show only 20 characters of author.
<?php $user_name_str = substr(get_comment_author(),0, 20); ?>
<?php printf(__('<cite><b>%s</b></cite> <span>says:</span>'), $user_name_str) ?>
I changed the this function as per my choose. You can customize this function as per your theme requirement.
Incoming search terms:
- edit wp_list_comments wp
- wordpress customize comments template
- wordpress theme if comments are closed form






I really liked your blog! good
Can anybody help me? I would like to sign up for the rss feed for this website, but not sure exactly what to do. I really like the information presented here. Thank You to anyone…
on top right side you can see the rss feed, facebook, twitter button. you need to click on rss feed button
Just landed on this place via Google seek. I love it. This situation change my perception and I am getting the RSS feeds. Cheers Up.
Get the plugin WP-DB-Backup. Install this into your WordPress blog under the plugin folder and activate it. Under ‘Tools’ there will be a Backup button that you can press. This is the area where you can set up an option to have this database emailed to you on a daily basis or at least once each week. Make sure you use an email that is not connected to your current hosting account in case the whole host gets attacked. Now you have your database automatically backed up.
Thanks, this was really helpful
Thank you for your great
content.
Great stuff as usual…
Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.
I feel a lot more people need to read this, very good info!
Hello,Fantastic article dude! i am Fed up with using RSS feeds and do you use twitter?so i can follow you there:D.
PS:Do you considered putting video to this web site to keep the visitors more entertained?I think it works.Best regards, Oliver Hano
It does seem that everybody is into this kind of stuff lately. Don’t really understand it though, but thanks for trying to explain it. Appreciate you shedding light into this matter. Keep it up
hello there, i just discovered your blog on bing, and i would like to comment that you write exceptionally good on your site. i am really motivated by the method that you compose, and the message is good. in any case, i would also love to acknowledge whether you would love to exchange links with my web portal? i will be more than happy to reciprocate and put your link off in the link exchange area. looking for your response, i give my sincere thanks and enjoy your day!
Good share, great article, very usefull for us…thanks!
How does this tie to one of the other posts? Maybe I’m blind… because I could’ve been on a differnet blog. lol Nevermind. At any rate, it was a solid post. Cheers
T. Saunderson
Halloween cookies
I was looking for crucial information on this subject. The information was important as I am about to launch my own portal. Thanks for providing a missing link in my business.
I admire what you have done here. I like the part where you allege you are doing this to come apart without hope but I would try on through all the comments that this is working also in behalf of you as well.
just posted this article on my facebook account. it is an interesting article for all.
Thank you very much for this script!
Me and my friend were arguing apropos an issue nearly the same to this! In the present circumstances I certain that I was right. lol! Thanks after the knowledge you post.
gooday there, i just discovered your website via yahoo, and i must say that you write exceptionally well on your web portal. i am truly motivated by the mode that you express yourself, and the subject is great. anyways, i would also love to acknowledge whether you would like to exchange links with my site? i will be certainly more than happy to reciprocate and put your link off in the link exchange area. looking for your answer, i would like to convey my appreciation and cheers!
Nice post…Thank you for sharing some good things.
Usefulinformation shared..Iam very happyto read this article..thanks for giving us nice info.Fantastic walk-through.
I thought I was the only one who had the same point of view.
haha,The Topic of your blog is very Suit to me, I hope more interflow with you this Subject.
Great post thx a lot of this, i Like it
Thank you for publishing this it was note for a paper I am right now writing for my finals. Thanks
[url
haha,The theme of your blog is very Suit to me, I hope more interflow with you this Topic.
Nice site,i have bookmarked it for later use, thanks.
Just read throught the whole topic. Seems interesting. A questions that has been bugging me about the gaming industry is how activision can continue to charge for DLC… Surely thats not right
A useful insight into How to customize the comments template or wp_list_comments() | WordPressapi.com – Developer Code book and ideas I will use in my blog. You’ve obviously taken some time on this. Many thanks!
You ought to seriously think about working on growing this blog into a dominant voice in this field. You obviously have a solid handle of the topics all of us are searching for on this site anyways and you could possibly even make a buck or two off of some offers. I would dive into following recent trends and raising the volume of blog posts you put up and I bet you’d begin getting some awesome traffic soon. Just a brainstorm, good luck regardless!
well done!nice job!
All extremely true, but I don’t support what you say myself. I will stay the more regular view. But I without doubt support your right to say what you want. Interesting anyway.
I like your site. great information too. I’ll come back later. I’m getting ready to go to the gym now.
Can you provide more information on this? take care
I can guess the hard work it must have been required to research for this post.All what i can say is just keep providing such post we all love it.And just to bring something to your notice,I have seen several blog providng your blog as source for this information.
Personally I use The Best Spinner, it really lives up to its name compared to the competition. You can check it out here http://bit.ly/re-writer (AFF)
Excellent job.
Are there any pictures available?
i’ll wait for your edition as well
I have to state, you chose your words well. The ideas you wrote on your encounters are well placed. This is an incredible blog!
Hello, I determined your weblog in a new directory of blogs. I dont know how your weblog came up, ought to have
Superb web site. It had been pleasant to me.
Your report has extra excellent value in your website. I say this due to the fact to me personally I find it priceless. Maybe to some 1 else it is not but to me you did very good. Thanks for your data.
Nice send mate!!?! Hold up the wonderful composing and we’ll retain coming back again for much more …)
Exceptional web page. It absolutely was pleasant to me.
I have this already, and I’d recommend that others look into it.
Hi VEry nice posts i’sure i’sts nice
Your blog is so informative ¡ keep up the good work!!!!
Very awesome article! Truely.
I feel you are too good to write Genius!Thanks for posting, maybe we can see more on this.
Interesting read, perhaps the best article iv’e browse today. We learn everyday cheers to you!
A truly very good publish by you my pal. I’ve bookmarked this web page and can are available again following several days to examine for just about any new posts that you simply make.
Nice article , THX !
Thanks for such a kick but post, you rock!
help me. I cannot read the first post properly. Thats what I came here to read so please help me.
I would like to say, nice webpage. Im not sure if it has been addressed, however when using Firefox I can never get the entire page to load without refreshing alot of times. Could just be my modem.
Brilliant blog posting. I found your post very interesting, I think you are a brilliant writer. I added your blog to my bookmarks and will return in the future.
Easily, the post is actually the greatest on this deserving topic. I agree with your conclusions and will thirstily look forward to your coming updates. . . . .
Excuse for that I interfere ?I understand this question. Is ready to help.
I think, that is not present.
Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.
I don¡¯t usually reply to posts but I will in this case. WoW
Your expert
Really nice and impressive blog i found today.
I bookmarked this guestbook. Thank you for real good position! .
My English is not good, but to see the article you write a good feel of your
You have some very good points there. I did a search about the subject and I want to let you know that I found out that almost all pros will agree with your opinion.
Enjoyed the post. This blog was worth bookmarking but this is going on Delicious now!
Nice site and great text.
One of my popular artists, thank you! It is possible to come across loads of their music this around at this web site
Wow!, this was a real quality post. In theory I’d like to write like this too – taking time and real effort to make a good article… but what can I say… I keep putting it off and never seem to achieve anything
Extraordinary post, I bet a lot of work and research went into this article. Your blog is so informative… keep up the neat work!
Very well written article. I’m really impressed by you knowledge of the subject. Fell free to write more.
Because of the obnoxious “Tweet/Facebook share/Buzz/Digg/etc” bar that hovered next to everything while I visited this page. I couldn’t actually concentrate on the information that brought me here. I even had to scroll tactfully to be able to see what I was writing in this comment field.
Because of that, I will never visit this website. It annoyed me enough, that I felt compelled to even write a comment saying so. I’m not sure what was even on this page, just an annoying bar telling me to promote this site on social sites.
Nice work, push away readers by trying to promote your site to get more readers. Not a very good UI plan.
thats a kick ass post.i wonder how long it took to come up with all this.you got talent.
keep it up
You, Sony, are the most important blogger at this moment for me =D
I’ve been searching around 2 hours around the net this and with no luck. I think there isn’t another easy way to get your comments like you want.
Thank you so much.
I really like my topic, My organization is with internet marketing/SEO. Have you ever heard from meetup.com? I find that there is usually a few decent probabilities to fulfill and netwoork online websites to our destinations. You ought to check it out should you receive period.
Aspirin is one of the most popular drugs in the world. Don’t become a slave; try to resist your pain! That’s what i want to say here.
It is great to have a style in posting comments and templates will also help. I have been doing blog comments everyday. I enjoyed it a lot. Thanks.
I am confused with the code comment in comment.php WPtypo.
Is it possible to make a comment thread on the theme that the code is
not wp_list_comments WPtypo (). ?
List Code Comment,php WPtypo
<li class="clearfixuser_id == $post->post_author)
{ echo ‘ author’; } ?>” id=”comment-”>
user_id === $post->post_author) echo ”; ?>
&& ‘Reply’,
‘add_below’ => $add_below, ‘depth’ => $depth, ‘max_depth’ =>
$args['max_depth']))); ?> user_id ===
$post->post_author) { echo “Penulis“; } ?>
comment_approved == ’0′) : echo
“Komentarnya saya simpen dulu di lemari yah
!!!“; endif; ?>
How about the other version of WordPress?
Anyway, I found this really helpful that is why I bookmark it because I am sure I will use it in the future.