Support » Fixing WordPress » Highlighting admin comments only

  • I’m trying to highlight just the admin comments in the comments list. I’ve tried a bunch of tutorials and I’ve had no luck. If someone could help/point me in the right direction it would be greatly appreciated.

    In the comments.php file I’m calling wp_list_comments

    <ol class="commentlist">
    		<?php wp_list_comments('type=comment&callback=cnc_comment'); ?>

    This is my function in the functions.php file:

    // Comments Callbacks, Pingbacks and Style
    	function cnc_comment($comment, $args, $depth) {
    	   $GLOBALS['comment'] = $comment;
    	   <li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?> ">
    		 <div id="comment-<?php comment_ID(); ?>" >
    		  <div class="comment-author vcard">
              <!--Avatar Call and Size -->
    			 <?php echo get_avatar($comment,$size='48'); ?>
    			 <?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
    		  <?php if ($comment->comment_approved == '0') : ?>
    			 <em><?php _e('Your comment is awaiting moderation.') ?></em>
    			 <br />
    		  <?php endif; ?>
    		  <div class="comment-meta commentmetadata"><?php printf(__('%1$s at %2$s'), get_comment_date(),  get_comment_time()) ?> <br /><?php edit_comment_link(__('[Edit Comment]'),'  ','') ?></div>
    		  <div class="comment-body">
    		  <?php comment_text() ?>
    		  <div class="reply">
    			 <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>

    Thanks in advance,

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael


    Forum Moderator

    that callback is integrating <?php comment_class(); ?> which might output comment author specific css classes;

    try and use a browser inspection tool such as Firebug to investigate what css selectors are output with the individual comments.

    if you need help with checking, please post a link to a post or page with at least one admin comment.

    Thanks for the reply. I see the issue in firebug but, I’m just not sure how to fix it.

    All the li tags have a class of this:
    <li id="li-comment-8" class="comment byuser comment-author-admin odd alt thread-odd thread-alt depth-1">

    In the class for all the user comments it’s showing up as comment-author-admin when it should be comment-author-“the user_id”

    Any clue on how to fix this?
    I would post a link but can’t due to confidentiality issues.




    Forum Moderator

    highlight just the admin comments

    that should be possible with the existing comment_class output; unless there is more than one user with admin capabilities.

    In the class for all the user comments it’s showing up as comment-author-admin

    might be a interference with some plugins;

    what theme are you using?

    when it should be comment-author-“the user_id”

    to get this output, you possibly need to add a filter function for ‘comment_class’ –

    Oh man, I just figured it out.

    It was actually working fine, but when I entered the posts and comments into the database manually I forgot to change the user_id’s from mine to the corresponding member’s, so that’s why they were all showing up as comment-author-admin.

    Everything is working good now. Thanks for the help and sorry that I wasted your time.


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Highlighting admin comments only’ is closed to new replies.