WordPress.org

Ready to get started?Download WordPress

Forums

Alternate Comment Colour and Author Highlighting (2 posts)

  1. Indyan
    Member
    Posted 5 years ago #

    I want to highlight comments made by me (uid=2) and otherwise use alternate background colours for comments.
    I created three classes in style.css

    .authcomment {
    background-color: #050C00;
    }
    
    .oddcomment {
    background-color: #EFE7FC;
    }
    
    .evencomment {
    background-color: #B3FCE8;
    }

    Now, I want to use authcomment for author comment, oddcomment for all odd no. comments and even comments for all even no. comments.

    Can someone please share the code for achieving this. I am not able to implement this properly.

    My blog : Pallab dot Net
    My full comment file

  2. texet
    Member
    Posted 5 years ago #

    It's really hard with the new comment loop. Anybody figure it out??

    This was easy to do with the old comment loop. Something like:

    <?php $comment_count++; if( $odd = $comment_count%2 ) { $commentclass="oddcomment"; } else { $commentclass="evencomment2"; }
    ?>

    And follow that with a conditional that checks whether the post author is making the comment, and if so, $commentclass = "authcomment". Finally, call it conditionally in the comment loop:

    echo '<div class="' . $commentclass . '">'

Topic Closed

This topic has been closed to new replies.

About this Topic