WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Testing comments for replies? (4 posts)

  1. Doodlebee
    Member
    Posted 3 years ago #

    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.

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

    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).

  3. Doodlebee
    Member
    Posted 3 years ago #

    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!

  4. Doodlebee
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.