Different backgrounds for comments…
-
How can I get all odds comments to have a grey background, and all even ones to have a white one?
-
You can check how it is done in the default theme. See the comments.php and the stylesheet.
That’s the only thing I can see???
<?php /* Changes every other comment to a different class */
if ('alt' == $oddcomment) $oddcomment = '';
else $oddcomment = 'alt';
?>Anyone?
What about it? You have the code right there…
It gives comment #1 CSS class A and then if the previous comment was given CSS class A, then it gives comment #2 CSS class B, then A, etc.
Or are you just not understanding what to do with that code?
This “might” help…please note I said “might”…
http://ww.wp.xz.cn/support/topic/24539?replies=24
http://ww.wp.xz.cn/support/topic/12668?replies=4#post-75051spencerp
I need to nknow where to insert the class names…
You don’t have to insert anything – just have that code in your comments.php. WP does the rest.
The only thing you have to do: define the .alt class in your stylesheet.Any example of .alt class for me?
Yes, in the stylesheet of the default theme.
Something like this: (Example ONLY!)
.commentlist li.alt {
background: #f0f;
}Got that from here:
http://ww.wp.xz.cn/support/topic/24539?replies=24#post-138514spencerp
I only get the header of the comment to be different?
I want the entire comment…Will any of these might help ya then:
http://www.scriptygoddess.com/archives/2004/06/21/comment-highlighting-based-on-author/
or
http://www.dailydoodles.dk/archives/2004/08/03/plugin-my-comments-for-wordpress/
or
http://mookitty.co.uk/devblog/archives/2004/07/28/comment-backgrounds-hack/Got that from here at this thread:
http://ww.wp.xz.cn/support/topic/12668?replies=4#post-75051spencerp
Hahaha…Silkjaer, anything….and I mean anything to get this solved! LOL! =)
[Goes back to working on a crappy theme=>…
spencerp
There is obviously something wrong…
See below:
http://www.coldplayfansite.com/wordpress/?p=3Code in comments.php is:
<div class="commentlist"><?php foreach ($comments as $comment) : ?>
<p class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">
<strong><?php comment_author() ?></strong>'s comment:
<?php if ($comment->comment_approved == '0') : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?><small><?php comment_date('F jS, Y') ?> at <?php comment_time() ?> <?php edit_comment_link('Edit comment','',''); ?></small>
<?php comment_text() ?>
<?php /* Changes every other comment to a different class */
if ('alt' == $oddcomment) $oddcomment = '';
else $oddcomment = 'alt';
?><?php endforeach; /* end for each comment */ ?>
</div>
And css is:
.commentlist p.alt {
background: #eeeeee;
}But only headers get the .alt and not the entire comment, which should be included since it’s between the 2
<p>
The topic ‘Different backgrounds for comments…’ is closed to new replies.