Forums

Comment Styling (14 posts)

  1. bendrucker
    Member
    Posted 1 month ago #

    I know you can easily highlight the author's comments. However, is it possible to highlight all comments from registered users? For example, I'd like the comments from the authors to be highlighted in green, and those from other writers that are registered to be blue. Can this be done?

  2. cais
    Member
    Posted 1 month ago #

    Most likely ... you might want to add a link to your blog with a specific post pointed out that would provide a good example of the comments you want to style.

    The more information you provide the better chance someone on these forums will have a quick (and easy?) answer for your question.

  3. bendrucker
    Member
    Posted 1 month ago #

    The blog is currently being constructed, so I don't have anything to show what I want to do. But here's an overview so my question is more clear. I want to create unique comment classes based on the following types of commenters:

    Author of Post: class="postauthor"
    Writer, but not author of given post: class="author"
    General user: Regular comment style

  4. esmi
    Member
    Posted 1 month ago #

    wp_list_comments() automatically generates .byuser and .bypostauthor classes. If they're not sufficient, you'll need to look at creating a custom comment callback function.

  5. bendrucker
    Member
    Posted 1 month ago #

    I checked the page and did not see any of the tags you mentioned. If they were there, that would be perfect for what I'm trying to do!

  6. esmi
    Member
    Posted 1 month ago #

    You need to examine the source of a page that is created using wp_list_comments to see all of the available classes.

  7. bendrucker
    Member
    Posted 1 month ago #

    I mean that I checked the source of a post page and there is no mention of the classes you referred to. Should I be looking somewhere else?

  8. esmi
    Member
    Posted 1 month ago #

    You need to look at a page that contain comments generated using wp_list_comments.

  9. bendrucker
    Member
    Posted 1 month ago #

    http://www.academicperspective.com/

    There's the URL. Could you tell me what page contains comments generated using wp_list_comments?

  10. esmi
    Member
    Posted 1 month ago #

    None. Your theme doesn't use wp_list_comments right now. You'd need to amend comments.php use that tag instead of it's current comment listing.

  11. bendrucker
    Member
    Posted 1 month ago #

    I managed to muster up my near non-existent PHP skills and get something working. I added this php code immediately after the div class=" for the comment div.

    <?php if($comment->user_id != 0)
    {echo 'usercomment';}
    if(get_the_author_meta('ID') == $comment->user_id)
    {echo ' authorcomment';}?>
  12. bendrucker
    Member
    Posted 3 weeks ago #

    So I've upgraded my theme and now it uses wp_list_comments instead of the legacy method. But the .byuser and .bypostauthor aren't appearing.

  13. bendrucker
    Member
    Posted 3 weeks ago #

    Anyone know how to make these classes appear?

  14. bendrucker
    Member
    Posted 1 week ago #

    Bump...

Reply

You must log in to post.

About this Topic