WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Code to tag the comments made by the author of a post (9 posts)

  1. su1
    Member
    Posted 3 years ago #

    Hello,

    I'm using a customized theme and it doesn't have the possibility to distinguish the comments made by the author of the post (like by adding the .bypostauthor class for example).

    I'm trying to find the code line that would permit me to add such a class. I think it's present in the twentyten theme, probably in the twentyten_comment function, but I can't spot it, can you help me please ?

    Here is the code of the twentyten_comment function:

    http://pastebin.com/fPjdKRMK

  2. esmi
    Forum Moderator
    Posted 3 years ago #

  3. su1
    Member
    Posted 3 years ago #

    Well I must say I have followed your link and I don't see any reference about adding specific tags for the author's comments.

    If you could be more specific it would be great.

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    The classes are automatically added by wp_list_comments().

  5. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    in the case of the callback function in twenty ten, the css classes are (automatically) added in this line:

    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">

    by the wordpress function comment_class() http://codex.wordpress.org/Function_Reference/comment_class

  6. su1
    Member
    Posted 3 years ago #

    Thank both of you for your reply.

    The comment_class function was messing up my theme so I just added this line :

    class="<?php if ($comment->comment_author_email == "contact@mydomain.com") echo 'author'; else echo 'user'; ?>"

    and it works fine.
    Thanks for your help.

  7. Caroline
    Member
    Posted 2 years ago #

    What can I do with this line to make sure my admin highlights?

    <li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">

    I tried with this one su1 had and it all went very wrong with the server.
    class="<?php if ($comment->comment_author_email == "contact@mydomain.com") echo 'author'; else echo 'user'; ?>"

  8. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    @makeupedia

    can you post a link to your site?

    what css classes are in the comment list at the moment?

    have you checked the link to the docu of comment_class() if that would output the admin.

    also, how to add extra classes to comment_class().

    what is the exact code of the full line?

  9. Caroline
    Member
    Posted 2 years ago #

    Sorry, I wasn't aware it was big trouble, just a minor fault!

    http://www.makeupedia.se

    I think this is the full line: http://pastebin.com/a9uDkMD9

    the commentlist classes

    .commentlist li.comment
    .commentlist li:last-child
    .commentlist ol
    .commentlist .avatar
    .commentlist .even
    .commentlist .bypostauthor
    .commentlist .children
    .commentlist .children li
    .commentlist li.comment+li.pingback

Topic Closed

This topic has been closed to new replies.

About this Topic