WordPress.org

Ready to get started?Download WordPress

Forums

Custom comment background color for all Admins (6 posts)

  1. devvv
    Member
    Posted 3 years ago #

    I've search for this topic and while there were many threads posted already, the answer isn't what I'm looking for.

    I would like to edit my website so that comments from all admin will have a distintive color from the rest of the users.

    Currently, the codes out there will only change the color of the author by comparing the emails.

    If multiple admins reply in the same post, only the author's comment background will be different.

    Your help will be greatly appreciated. :)

  2. Lynn
    Member
    Posted 3 years ago #

    devvv,

    See if this page helps you:
    http://www.mattcutts.com/blog/highlight-author-comments-wordpress/

    It matches the user id, so it looks like you would just have to modify it to test for multiple user ids for all your admins. If you can't modify it, you might just have to have one user (one id) be the official responder to comments.

    I hope the link hleps you. I am about to give it a try myself and will post something if I learn anything useful beyond what that link tells you.

  3. Lynn
    Member
    Posted 3 years ago #

    Hey, devvv,

    I am finding out more info by seeing if there is a plugin that does this. I found one but it was done in 2005. In the meantime, take a look at this from the WordPress.org site:

    http://codex.wordpress.org/User:Jalenack/Comment_Loop_Beauty

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Have you looked at the source code of your comments to see if your theme outputs specific admin classes that you could style on?

  5. Lynn
    Member
    Posted 3 years ago #

    Thanks, esmi.

    Yes, and unless I mistaken (not being a PHP expert), it doesn't. There is only this:

    /* This variable is for alternating comment background */
    $oddcomment = 'class="alt" ';

    I have tried a few plugins and none work. Either they are old and the code they tell me to replace in comments.php doesn't match anything in comments.php, or using their php-free set up interface does nothing at all to change comment colors.

    I think I am using a pretty non-standard theme
    Foundation 1.0.3 by Organized Themes
    http://www.organizedthemes.com/

    It has its own additional comments-functions.php file something I have never seen on any other theme. That one might have soething I can work with?
    E.g.,
    <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">

    and <div class="comment-content">
    <?php if ($comment->comment_approved == '0') : ?>
    <p>Your comment is awaiting moderation.</p>
    <?php endif; ?>
    <?php comment_text() ?>
    </div>

    But I don't know PHP well enough to tell.

  6. Lynn
    Member
    Posted 3 years ago #

    I spent some serious time on this, and finally found out that since Version 2.7, WordPress outputs a CSS class that you can use (see WordPress excerpt below). The class is "byauthor", and adding this line to my style.css did the trick in setting the author's comments apart:

    li.bypostauthor {
    /* CSS styles for author comments */
    background-color: #d4e5b1 !important;
    }

    No need to edit the PHP, just using and styling the WordPress-created class did the trick.

    http://codex.wordpress.org/Migrating_Plugins_and_Themes_to_2.7/Enhanced_Comment_Display
    ---------
    The new comments loop automatically puts every comment into a list (li) tag, and threads them as well. It adds classes on all HTML list tags that surround every comment in this fashion:
    * comment, trackback, pingback classes get added depending on the type of the comment.
    * byuser gets added if the comment is by a registered user of the site.
    * comment-author-authorname gets added for specific registered users.
    * bypostauthor gets added if the comment is by the author of the post the comment is attached to.
    * odd and even classes are added to odd and even numbered comments
    * alt is added to every other comment
    * thread-odd, thread-even, and thread-alt classes are the same as the odd/even/alt classes, but these only apply to the top level of each set of comments and replies
    * depth-1 is added to the top level comments, depth-2 to the next level, and so on.
    * children class is added to all threaded comments below the parent list
    -------

    I leave it to someone else to figure out the multi-admin problem, but these links might provide some clues:
    http://codex.wordpress.org/Template_Tags/comment_class

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.