WordPress.org

Ready to get started?Download WordPress

Forums

Highlighting admin comments only (5 posts)

  1. Dying2Live
    Member
    Posted 1 year ago #

    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'); ?>
    	</ol>

    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()) ?>
    		  </div>
    		  <?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>
    		  <div class="reply">
    			 <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
    		  </div>
    		 </div>
    	<?php
        }

    Thanks in advance,
    Mike

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

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

    http://codex.wordpress.org/Function_Reference/comment_class

    try and use a browser inspection tool such as Firebug http://getfirebug.com/ 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.

  3. Dying2Live
    Member
    Posted 1 year ago #

    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.

    Thanks

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    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' - http://codex.wordpress.org/Plugin_API/Filter_Reference

  5. Dying2Live
    Member
    Posted 1 year ago #

    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.

    Mike

Topic Closed

This topic has been closed to new replies.

About this Topic