PurabTech is technical blog for Programmer and Coders
How to customize the comments template or wp_list_comments()
In single.php file we have function to add comments functionality. Here in this article I will give the code for customize the comments template.
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. wordpress comments is very important functionality. Here in this article I will give the code for customize the comment 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
[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
<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>
<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 endif; // If registration required and not logged in ?>
88
</div>
89
90
<?php endif; // if you delete this the sky will fall on your head ?>
91
</div>
In the comments loop for showing the comments we used the wp_list_comments() function. Use this for customize the comments template.
We can customize this function as per our requirement. We can pass the following parameters to this function. use following for customize the comments template.
[/viral-lock]
For customize the comments template following 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.
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.
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 (). ?
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.
You, Sony, are the most important blogger at this moment for me =D
I’ve been searching 2 hours 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 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; ?>
Sharp thkgiinn! Thanks for the answer.
Well,excellent,but one more question I come across,I have post the question to wordpress web
here is the link:http://wordpress.org/support/topic/customizing-children-comments-in-wp_list_comments-in-wordpress?replies=2
this kind of a comment box like this is a plugin?