WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Testing comments for replies?

[Resolved] Testing comments for replies?

  • Anyone know if there’s some method of testing to see if a comment has replies? I can easily grab the parent ID of comments, but I need to add a class to a comment if it has replies (children) to it. I can’t, for the life of me, figure out how to do so.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Michael

    @alchymyth

    Forum Moderator

    looking into /wp-includes/comment-template.php (line 1348; part of the comment walker), there is this line:

    <<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">

    the code empty( $args['has_children'] ) ? '' : 'parent' seems to work if used in the comment-callback function in twenty ten.

    it seems that a theme with standard wp_list_comments() would have the css class .parent automatically on the <li> tag of comments with replies (untested).

    Cool – I’ll give that a shot. (I’m using the “div” instead of “li”, so I don’t know if that makes a difference) – thank you so much!

    YES! You are a HERO. Thank you SO MUCH!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Testing comments for replies?’ is closed to new replies.
Skip to toolbar