Codex

Template Tags/comment class

This page is marked as incomplete. You can help Codex by expanding it.

WordPress includes a new function for comment classes, which will help theme authors perform simpler styling. The function is, appropriately enough, called comment_class().

See also post_class() for more details.

<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">

The comment_class() outputs the class="whatever" piece for that div. This includes several different classes of value: comment, even (or odd), thread-even, depth-1, etc.. These make it easy to style different parts of the theme in different ways.

For special cases where you want to add your own classes, post_class supports that too:

<?php comment_class('special'); ?>

This will add "special" to the class list.


See also