Article in detail

Comments Tweak in Wordpress -1

Written on 6 .Oct. 2006 and has No Opinions

Making your comments section look nice

You need to know some CSS and have a fair idea of how a PHP code works.

Have you come across those sites where comments are displayed beautifully with a separate look for author comments and an alternating look for the rest of the folk?

Chilligavva too carries this style. Take a look. I shall quickly tell you how to do the same with your wordpress blog. There are two steps, step-1 the code manipulation and step-2 defining the styles for the same.

Part-1: Manipulating the code

Look for the following code in comments.php located in the folder
“wordpress-folder / wp-content / themes / current theme / “

<?
if ($comments) :
foreach ($comments as $comment) :
$isByAuthor = false;
if($comment->comment_author_email == ‘email@domain.com’) {$isByAuthor = true; }
?>
 

And replace it with the following code

<? if ($comments) :
foreach ($comments as $comment) :
$isByAuthor = false;
if($comment->comment_author_email == ‘email@domain.com’) { $isByAuthor = true;}
if (‘alt’ == $oddcomment &amp;&amp; $isByAuthor == true) $oddcomment = ‘auth’;
elseif (‘alt’ == $oddcomment &amp;&amp; $isByAuthor == false) $oddcomment = ‘def’;
else $oddcomment = ‘alt’;
?>

Make sure that you substitute the generic “email@domain.com” in the above code with the actual email of the author, as defined in the wordpress settings.

Part 2: Defining styles in style.css

Lakshmi Mareddy is a polyglot from South India and is interested in design, technology, UI and human computing. She also is a history buff and an avid reader. If you like the way she writes, why dont you subscribe to the site feed via RSS or Email? Its absolutely free and helps you stay current. You can contact her via the contact page or write to lak [at] mareddy [dot] com.

Share your thoughts

Note: Your comments may take time to appear, as they are moderated for the first time.. All comments are followed. Your Personal Info will not be shared. Still have concerns? Read the rights and privacy details of Chilligavva..

 
Security Image
 
CommentLuv Enabled

Life is a process. You are a process. The universe is a process.