This was originally posted by me on Castle Made – however, I thought I would repost this popular post before removing Castle Made.

The default template will have all the usual details. Username, gravatar and comment etc. The issue isn’t the content (unless you care about the format of the date to match the rest of your website) – the issue is the layout.

By adding some code to the functions.php file in your Wordpress theme folder, you can have more control over what is going on. The following is the template used on Castle Made.

<?php
function cust_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>" class="aComment">
	<div class="commenter">
		<div class="gravatar">
			<?php echo get_avatar($comment,$size='140'); ?>
		</div>
		<?php printf(__('<h4><cite class="author">%s</cite></h4>'), get_comment_author_link()) ?>
		<div class="comment-meta commentmetadata"><?php printf(__('%1$s'), get_comment_date(), get_comment_time()) ?></div>
	</div>
	<div class="theComment">
	<?php comment_text() ?>
	<?php if ($comment->comment_approved == '0') : ?>
	<p><em><?php _e('Your comment is awaiting moderation.') ?></em></p>
	<?php endif; ?>
	</div>
</div>
<?php } ?>

The important part is to now trigger the template change. Open up your theme’s comments.php file, and go to line 29 (default theme) and look for the following code:

<?php wp_list_comments(); ?>

And change it to the following:

<?php wp_list_comments('callback=cust_comment'); ?>

The value of ‘callback’ must match the name of your comments function.

4 comments

  1. Kicker

    Everything dynamic and very positively! :)
    Have a nice day
    Kicker

  2. WP Themes

    Nice fill someone in on and this enter helped me alot in my college assignement. Thank you for your information.

  3. Affectionate beauty

    In my opinion you stole this article and placed on another site. I had already seen.

  4. Simon

    @affectionate beauty: I did state that in my opening sentence that I originally posted this article on my other website (Castle Made).

Leave a Reply


About

I am a Scarborough (England) based web designer who specialises in creating attractive and usable websites. I currently work for Save9 Ltd. and also do freelance work in my spare time. I have been designing websites since the age of 15. So that's 7 years of web design experience. Read more about Simon Wilans.

Twitter

Follow @willans

Bookmarks

  • No bookmarks avaliable.