I've put the following code above print render($content['comments']);
in comment-wrapper.tpl.php
of our theme to add question
or answer
class to every comment:
foreach($content['comments'] as &$c) { if(is_array($c) && array_key_exists('#entity_type', $c) && $c['#entity_type'] == 'comment') { $uid = $c['comment_body']['#object']->uid; $c['#attributes']['class'][] = $uid == 1 ? 'answer' : 'question'; } }
The generated HTML however has no question
or answer
classes. Please help me to correct the error.