Code Snippet
Customize Comments Markup
In a typical WordPress theme you output the entire list of comments for a Post/Page by using the function wp_list_comments(). This doesn't offer much by the way of customizing what HTML markup gets generated for that comment list. To write your own markup for the comment list, you can use a callback function as a parameter in wp_list_comments(), so it's just as nicely abstracted.
In functions.php
<?php
function my_custom_comments($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<?php endif; ?>
// Comments markup code here, e.g. functions like comment_text();
</li>
}
?>In comments.php
<?php
wp_list_comments("callback=my_custom_comments");
?>
Pasted as is, this breaks my functions file.
God, I swear there’s like NOTHING out there that thoroughly explains comments for WP.
I completely agree. I’m building my first theme and I can’t find anything on the web that gives a great “tutorial-like” breakdown of customizing the comments section. SOOOO frustrating.
Good theory. I like it. Appreciate your posting
thanks.. very good
The reason is breaks is because the php tag isn’t opened at the end with the closing bracket. It should look like the above code.