How to remove the "Add new Comment" link from book pages I have created two books, and both of them have child pages (which are also book pages). I have activated the option of commenting, in which the comment box is shown in the same book page.

All works fine when there is no comment on a particular page, but even when any user posts at least one comment on the page, the "Add New Comment" button appears in the links area below page-links and above the comment-wrapper; the comment box is shown below. I just wanted to ask how to remove this link because it is messing with the other options in the links area (e.g. printer friendly page, PDF).

I did create a hook using the following code.

&lt;?php
  /**
  * Implementation of hook_link_alter
  * Remove add comment link from a content type
  * MODULENAME = remove_comment
  **/
  function MODULENAME_link_alter(&amp;$links, $node){
    if($node-&gt;type == 'book'){
      unset($links['comment_add']);
    }
  }
?&gt;


I have set the permissions for the users to post comments and have kept the comment box open by default. So, it makes no sense in having the Add new comment link.

And in admin/structure/types/manage/book, the settings are as shown below.
I did get the solution and was able to remove the "Add new comment" link, from the links area. I just went to comment module and commented the following lines of code on line #675.

// Show the "post comment" link if the form is on another page, or
// if there are existing comments that the link will skip past.
if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE || (!empty($node-&gt;comment_count) &amp;&amp; user_access('access comments'))) {
  $links['comment-add'] = array(
    'title' =&gt; t('Add new comment'),
    'attributes' =&gt; array('title' =&gt; t('Share your thoughts and opinions related to this posting.')),
    'href' =&gt; "node/$node-&gt;nid",
    'fragment' =&gt; 'comment-form',
  );
  if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) {
    $links['comment-add']['href'] = "comment/reply/$node-&gt;nid";
  }
}


I know it is not recommended to modify the core. I have implemented a hook to remove the link.

Solution found
The following hook in my custom module works for me :)

function MODULENAME_node_view_alter(&amp;$build) {
  if ($build['#node']-&gt;type == 'book') {
    unset($build['links']['comment']['#links']['comment-add']);
  }
}