How can I assign a specific id to the last comment of a post

I guess you use the comments loop(?). If so, you could

Possibility A

count the comments first, set $i = 0; before the loop and $i++ at the beginning/inside the loop and then attach your needed id when `if ( $count < $i ) $css_id = “id=’last-comment'”.

Possibility B

You could take the comments object(?) and use $last_comment = count( $comments_obj ); and after the loop echo $comments->$last_comment;. If it’s an array, you should use echo $comments[ $last_comment ]; of course.


Not sure which one works as I haven’t dealt with comments for a while, but it should get you on the right track.