WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Admin comment highlight messes up alt comment styling (8 posts)

  1. Doodlebug
    Member
    Posted 6 years ago #

    Hi,

    I'm using the method from this page:
    http://www.mattcutts.com/blog/highlight-author-comments-wordpress/

    ...to highlight my own comments as admin/author of my blog.

    However, implementing that code has resulted in the styling I created for alternate posts (eg. every other comment has a different background colour) from working.

    Looking in the source of my page in the browser, it shows an alternate comment as having this class...

    <li class="class="alt" "id="comment-7">

    So obviously something has gone wrong but my PHP skillz can't solve this simple problem.

    Any help is appreciated!

  2. Jeremy Clark
    Moderator
    Posted 6 years ago #

    That is way I used to setup my author highlighting.

    <li class="<?php echo $oddcomment; ?> <?php if ($comment->user_id == '1') echo 'author'; ?>" id="comment-<?php comment_ID() ?>">

    $oddcomment is my alternating variable class.

    You might want to post your comment template to http://wordpress.pastebin.ca and give a link.

  3. Doodlebug
    Member
    Posted 6 years ago #

    I've uploaded what my comments.php code looks like here:
    http://wordpress.pastebin.ca/1173219

  4. Doodlebug
    Member
    Posted 6 years ago #

    Line 17 seems to have the format for the bad class being spat out, but this is in the bit that shouldn't and wasn't edited.

  5. Jeremy Clark
    Moderator
    Posted 6 years ago #

    Here's the updated template.
    http://wordpress.pastebin.ca/1173229
    Line 17 was the culprit.

  6. Jeremy Clark
    Moderator
    Posted 6 years ago #

    We cross-posted there a little. I think that guide assumed a little to much about your setup.

  7. Doodlebug
    Member
    Posted 6 years ago #

    Weirdly I copied in your method for line 29 (from your first reply) and then used your fix for line 17. The problem still persisted, but this time some of the highlighted admin comments weren't highlighted anymore.

    Because as well as
    <li class="class="alt" " id="comment-6">
    it would give
    `li class="class="alt" authcomment" id="comment-8">'
    when a post was both admin highlight and alternate.

    So I changed line 29 back to how I had it at the start and the original problem remains.

    This is really quite strange.

    I normally test changes on my localhost, but i've added a few comments to the actual blog here: http://doodlebug.josephlavington.com/?p=17

  8. Doodlebug
    Member
    Posted 6 years ago #

    OK, so I believe i've now fixed this.

    Line 51 had a similar problem to line 17, so change it (51) to:
    $oddcomment = ( empty( $oddcomment ) ) ? 'alt ' : '';

    I'm no PHP expert, so if you think this isn't the right way to do it, please let me know!

Topic Closed

This topic has been closed to new replies.

About this Topic