WordPress.org

Ready to get started?Download WordPress

Forums

Simple Author Highlighting and alternate post highlighting combined (9 posts)

  1. SimonDorfman
    Member
    Posted 9 years ago #

    I'm using WP 1.5 and a hacked up version of the Kubrick theme. I changed the code exameple here:
    http://blog.deconcept.com/2004/11/13/wordpress-author-comment-highlighting/
    ...so it works with the alternate highlighting in Kubrick. In the comments.php file replace this (should be line 29):
    <li class="<?php echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">

    ...with this line:
    <li class="<?php if ($comment->comment_author_email == "you@youraddress.com") echo 'mycomment'; else echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">

    Then add this to your syle.css:
    li.mycomment {
    background-color: #FFFFF7;
    border: solid 1px #5B0100;
    }

    Works fine for me. See it in practice here:
    http://simondorfman.com/Games/Spellfire/2005/03/12/to-the-pain-thieves-deck/#comments

  2. sithicus
    Member
    Posted 9 years ago #

    can we nest an if this for two authors?

  3. sithicus
    Member
    Posted 9 years ago #

    btw very nicely done.

  4. sithicus
    Member
    Posted 9 years ago #

    This is how I addapted it for two authors :)

    Then of course make your style sheets different.

    <li class="<?php if ($comment->comment_author_email == "email1@gmail.com") echo 'christopher'; else if ($comment->comment_author_email == "email2@gmail.com") echo 'christine'; else echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">

  5. obeattie
    Member
    Posted 8 years ago #

    Is there a way of doing this by fetching the author's email direct from WordPress?

  6. silencematters
    Member
    Posted 7 years ago #

    Is there a way of doing this by fetching the author's email direct from WordPress?

    Great question. I would like to be able to do the same!- jeremy

  7. silencematters
    Member
    Posted 7 years ago #

    What if you have 20+ writers on a blog? it wouldnt make sense to go into comments.php each time I have a new user, right? I bet there is a more efficient way.

  8. Kafkaesqui

    Posted 7 years ago #

    Mod to Simon's original:

    <li class="<?php if ( $comment->comment_author_email == get_the_author_email() ) echo 'authorcomment'; else echo $oddcomment; ?>" id="comment-<?php comment_ID() ?>">

    Change the .mycomment class to .authorcomment in the css.

  9. Michael Bishop

    Posted 7 years ago #

    Thanks Kaf, I was looking at the functions on how to do this, and thought, maybe it's already been asked in the forums, and lo and behold, it had. Worked like a charm.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.