WordPress Tips : Alternating Colors For Comments

by 6 years ago

Alternating Colors For Comments

In most of the WordPress themes, comments display are simple and regular. In such themes it becomes hard to distinguish two comments.
To make your comments well organized and clear, you should color alternate rows of your comments. Alternating rows make it easier to distinguish one comment from another.
Here in this article I am going to give you a quick and easy to implement tip to alternating Colors for comments.

How to Color Alternate Comments?


It’s quite easy, you will have to follow me and do some editing in your WordPress PHP files.
Although it is safe but we recommended you to create backups of you files before editing.

 

Step 1: Go to your Dashboard -> Appearances -> Editor. Open Style Sheet(css file) and paste the following code at the top of the file.

.color1 {
background-color: #DBDBDB;
}
.color2 {
background-color: #EEEEEE;
}

Step 2: In the Editor now open comments.php and Paste the following code at very top of the file.

<?$i;?>

Step 3: Now Staying in same file comments.php, scroll down and find out the following part of the code.


<?php foreach <?php foreach ($comments as $comment) : ?>
<div class="commentbox">
<div class="commentid">($comments as $comment) : ?>
<div class="commentbox">
<div class="commentid">

Now, Replace above code with the following code.


<?p<?php foreach ($comments as $comment) : ?>
<div id="commentbox"
class="<?=($i%2)?"color1":"color2"
;$i++;?>">
<div class="commentid">hp
foreach ($comments as $comment) : ?>
<div id="commentbox"
class="<?=($i%2)?"color1":"color2"
;$i++;?>">
<div class="commentid">

All done! Update you file , go to your website and enjoy the well organized comment area of your blog or website.

If you have any other trick to improve comment area of WordPress websites or blogs please post in the comments.

Comments

Load More