Like the article? Be sure to subscribe to our RSS feed and follow us on Twitter to stay up on recent content.

First, we should take a look at the code from the tutorials which highlight the comment based on the user ID:

.authcomment {
    background-color: #B3FFCC !important;
}

<li class=”<?php 

                if (1 == $comment->user_id) 
                    $oddcomment = “authcomment”; 
                echo $oddcomment;?>” id=”comment…">
                
                ...
                
</li>

To make it work on sites with multiple writers, we need to to get the ID of the author, then check if the ID of the person posting this comment is the same. If it is, we need to make it stand out. We still use the CSS class for post author comment.

.authcomment {
    background-color: #B3FFCC !important;
}

Now, we change the original code at the start of the article with this:

<li class="comment-container 
    
    <?php
        $authID=get_the_author_meta('ID');
                                    
        if($authID == $comment->user_id)
            $oddcomment = 'authcomment';
        echo $oddcomment;
    ?>"  id="comment-<?php comment_ID(); ?>">
                                    
        ...
        
</li>

And, that’s it! We hope that you find it useful!