I've been at this for a few hours now but can't find a good way to solve this.

Basically what i want to achieve is to trough my template.php file completely override the comment modules output of links when displayed on a node teaser.

So i want to remove the "Add New Comment", "2 New Comments", "2 Comments" for example and have it replaced by only one single button saying something like "Comments (2)" instead.

1 Answer 1


This specifically answers your question on how to override the comment links. The important part is using the value of $vars['comment_count'] to add the count into your altered link title.

function YOURTHEME_preprocess_node(&$vars) {
        // Get rid of other comment link with counts
        $vars['content']['links']['comment']['#links']['comment-comments'] = array();
        // Override the title of the add a comment title displaying a count
        if($vars['comment_count'] > 0)
            $vars['content']['links']['comment']['#links']['comment-add']['title'] = 'Comments ('.$vars['comment_count'].')';
            $vars['content']['links']['comment']['#links']['comment-add']['title'] = 'Comments';

Not the answer you're looking for? Browse other questions tagged or ask your own question.