• I’m trying to using the comment_class function for my comments so I can style them properly (different color for post author’s comments, alternating colors, etc). However, it looks like the function is appending the comment ID before “class=…” such that often the returned string looks like this:

    5class="comment byuser comment-author-admin bypostauthor even thread-even depth-1"

    Note the “5” right before “class”. 5 is the id of the comment that’s currently being used, but it could be the ID of any comment.

    Anyone has an idea of what’s up? I’ve looked into comment-template.php but I don’t see anything wrong. By the way, this only occurs if I specifiy a comment id in the function’s args.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think there’s a problem in your callback function.

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

    works perfectly for me.

    Actually I have the same issue. WP is outputting an entire class=”class info here” rather than just class info here. I also have an issue like this since I am using a class system for a comment div, and I want to add just the name of the respective classes in the same line but it outputs the entire thing, which basically screws up the CSS.

    If you want to add a class of your own use this:

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

    It works just like post_class().

    Hope that helped,

    gd

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Broken comment_class() is adding comment id to beginning of returned string’ is closed to new replies.