Is there a way I can programmatically edit comment reply links for a specific content type in Drupal 7?

So I need to check for the content type before changing the links:

if ($node->type == 'book') {
  // change comment reply links here

Does anyone know how this can be achieved? Is there some sort of hook I need to implement?

1 Answer 1


You can try to use preprocess comment function:

function MYTHEME_preprocess_comment(&$vars) {

Also check https://www.drupal.org/node/319298

  • Can I put this into my custom module? Commented Mar 22, 2016 at 10:16
  • yes, put it into your module and change MYTHEME_ to your module name. OR put this function into template.php and chnage to your theme name
    – smile
    Commented Mar 22, 2016 at 10:19
  • Oh I see, how about if I want to change the href link instead of unsetting it? Commented Mar 22, 2016 at 10:20
  • try to debug $vars['content']['links']['comment']['#links']['comment-reply'] , I guess it should contain 'href' attribute there
    – smile
    Commented Mar 22, 2016 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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